Ping Works: Setting Up Ubuntu 24.04 VXLAN Overlay Network for Two Hosts

Abstract: Configure a VXLAN overlay network between two Ubuntu 24.04 hosts using manual ip link commands and kernel modules.

Created: 2026-09-23 by

Establishing a VXLAN overlay between two Ubuntu 24.04 hosts requires configuring the Linux kernel module and using ip link commands, as Netplan does not natively support VXLAN creation in its standard YAML syntax. This guide details the manual configuration steps to create a virtual network interface that encapsulates traffic over your existing physical connection.

Prerequisites and Kernel Module Loading

Before configuring the overlay, ensure the underlying infrastructure is ready. Both Host 1 (H1) and Host 2 (H2) must be running Ubuntu 24.04 LTS. The primary requirement is that the vxlan kernel module is loaded on both machines. You can verify this by running:
lsmod | grep vxlan
If the module is not listed, load it manually with:
sudo modprobe vxlan
To make this persistent across reboots, add vxlan to /etc/modules-load.d/vxlan.conf. Ensure that your physical network interfaces are up and that you have basic IP connectivity between the two hosts. If you are unsure how your server interfaces are currently managed, refer to our guide on How do Ubuntu-server network interfaces work? to understand the difference between legacy ifupdown and modern NetworkManager or Netplan backends.

Configuring Host 1 (H1)

On the first host, we will create a VXLAN interface named vxlan0. We assign it a Virtual Network Identifier (VNI) of 100. The critical parameter is remote, which points to the public or private IP address of Host 2. Execute the following command on H1. Replace H2_IP with the actual IP address of the second host.
sudo ip link add dev vxlan0 type vxlan id 100 remote H2_IP dstport 8472 dev eth0
sudo ip addr add 10.0.0.1/24 dev vxlan0
sudo ip link set vxlan0 up
Breakdown of the flags:
  • id 100: The VNI. This must match the VNI configured on H2.
  • remote H2_IP: The destination IP for encapsulated packets.
  • dstport 8472: The standard UDP port for VXLAN traffic.
  • dev eth0: The physical interface used for underlay routing.
After execution, verify the interface status with ip link show vxlan0. It should show state UP. Assign the IP 10.0.0.1/24 to this new virtual interface.

Configuring Host 2 (H2)

The process on the second host is symmetric but reversed regarding the remote IP. On H2, run the equivalent commands, replacing H1_IP with the IP address of Host 1.
sudo ip link add dev vxlan0 type vxlan id 100 remote H1_IP dstport 8472 dev eth0
sudo ip addr add 10.0.0.2/24 dev vxlan0
sudo ip link set vxlan0 up
It is crucial that the VNI (id 100) matches exactly what was set on H1. If the VNIs differ, the kernel will drop the encapsulated packets because it treats them as belonging to different logical networks. Also, ensure the subnet mask (/24) is consistent so that ARP resolution works correctly within the overlay.

Testing Connectivity

Once both interfaces are up, test the overlay by pinging from H1 to H2’s overlay IP:
ping 10.0.0.2
If the ping succeeds, the VXLAN tunnel is operational. If it fails, check the following:
  1. Firewall Rules: Ensure UDP port 8472 is open on both hosts. Use sudo ufw allow 8472/udp if using UFW.
  2. Routing: Verify that the underlay route to the remote host exists. Run ip route get H2_IP on H1 to confirm it routes through eth0.
  3. MTU Issues: VXLAN adds 50 bytes of overhead. If your physical MTU is 1500, the effective MTU for the overlay is 1450. Consider setting mtu 1450 on the vxlan0 interface if you experience packet drops with larger payloads.
For more context on how VMs communicate through hosts, see How to Configure a Traffic Route from VM1 through Host to VM2, as the principles of underlay routing apply similarly here.

Making Configuration Persistent

Since these commands are run via iproute2, they will disappear after a reboot. To persist the configuration on Ubuntu 24.04 without relying on unsupported Netplan VXLAN blocks, you can use a systemd service or a network dispatcher script. Create a file at /etc/systemd/system/vxlan-setup.service:
[Unit]
Description=Setup VXLAN Overlay
After=network-pre.target
Before=network.target

[Service]
Type=oneshot
ExecStart=/bin/bash /usr/local/bin/setup-vxlan.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Then create the script /usr/local/bin/setup-vxlan.sh:
#!/bin/bash
# Wait for network to be ready
sleep 10

# Define variables
VNI=100
REMOTE_IP="H2_IP" # Update this per host
LOCAL_IP="10.0.0.1" # Update this per host
PHYS_DEV="eth0"

# Remove existing interface if present
ip link del vxlan0 2>/dev/null

# Create VXLAN
ip link add dev vxlan0 type vxlan id $VNI remote $REMOTE_IP dstport 8472 dev $PHYS_DEV

# Set IP and bring up
ip addr add $LOCAL_IP/24 dev vxlan0
ip link set vxlan0 up
Make the script executable with chmod +x /usr/local/bin/setup-vxlan.sh and enable the service with systemctl enable vxlan-setup.service. Note that you must update the REMOTE_IP and LOCAL_IP values in the script for each host individually.

Troubleshooting Common Issues

If you encounter issues where ping works but throughput is low, check for asymmetric routing. Ensure that return traffic from H2 also goes through the VXLAN interface. You can inspect the ARP table on H1 with ip neigh show dev vxlan0. If the entry for 10.0.0.2 is incomplete, try flushing the cache with ip neigh flush dev vxlan0 and pinging again. Additionally, verify that no other services are conflicting with the IP addresses assigned to the overlay. If you previously had a VM setup that used similar subnets, ensure there is no overlap. For those migrating from older Ubuntu versions, note that networking behaviors may differ slightly from Ubuntu 22.04 setups, as discussed in Ubuntu 22.04 VM on KVM/virt-manager Not Connecting to Internet.

Frequently Asked Questions

Why doesn't Netplan support VXLAN directly?

Netplan is primarily a renderer abstraction layer that generates configurations for NetworkManager or systemd-networkd. Neither backend has native, stable support for creating VXLAN interfaces via their primary configuration files in Ubuntu 24.04. Using iproute2 scripts provides a reliable workaround that bypasses these limitations.

What happens if the VNIs do not match?

If the VNI (Virtual Network Identifier) differs between the two hosts, the kernel will treat the incoming packets as belonging to a different logical network. Consequently, the packets will be dropped, and you will not be able to ping or communicate between the overlay interfaces, even if the physical network is perfectly connected.

Can I use a different UDP port than 8472?

Yes, you can specify any valid UDP port using the dstport flag. However, 8472 is the IANA-assigned default port for VXLAN. Using non-standard ports may cause issues with firewalls or network appliances that expect standard VXLAN traffic patterns, so sticking to 8472 is recommended unless required otherwise.

How do I debug VXLAN packet drops?

Use tcpdump -i eth0 udp port 8472 on both hosts to verify that encapsulated packets are being sent and received. If you see outgoing packets but no incoming ones, check your firewall rules (UFW or iptables) to ensure UDP 8472 is allowed inbound. Also, verify that the remote IP resolves correctly and is reachable via ICMP ping.

Does this setup work with IPv6?

The examples provided use IPv4. To use IPv6, replace the IPv4 addresses with IPv6 equivalents and ensure the dev parameter points to an interface capable of IPv6 routing. The logic remains identical, but you must configure the appropriate IPv6 prefixes and ensure your underlay network supports IPv6 routing to the remote host.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More