The Multi-Cloud Networking Headache
Connecting virtual machines across cloud providers quickly exposes routing headaches. Overlapping CIDR blocks, rigid VPC peering constraints, and proprietary firewalls get in the way fast. When worker nodes run across AWS us-east-1 and a bare-metal Hetzner box in Germany, treating them as members of one local switch is surprisingly tricky.
Standard VPN tunnels like WireGuard or OpenVPN handle encryption well. However, they operate strictly at Layer 3. That becomes an obstacle if your workload needs flat Layer 2 broadcast domains, virtual MAC addresses, or cluster discovery protocols relying on multicast and raw ARP. Routing Layer 3 frames through custom NAT configurations adds fragile complexity.
Virtual Extensible LAN (VXLAN) bridges this gap cleanly. By wrapping Layer 2 Ethernet frames inside standard UDP packets on port 4789, VXLAN builds a virtual switched network over any routable IPv4 or IPv6 infrastructure.
Core Concepts: How VXLAN Operates Under the Hood
Understanding kernel packet handling makes troubleshooting overlay networks straightforward.
VNI (VXLAN Network Identifier)
Standard 802.1Q VLAN tags use 12 bits, limiting you to 4,094 distinct virtual network segments. VXLAN uses a 24-bit identifier called the VNI. This expands your namespace to 16,777,216 isolated segments. Even for a modest three-node setup, VNIs isolate test environments without complex sub-interfaces.
VTEP (VXLAN Tunnel Endpoint)
A VTEP encapsulates outbound Ethernet frames into UDP datagrams and strips headers from incoming packets. In Linux, the kernel handles encapsulation directly via virtual network interfaces managed by iproute2. The underlying public or private network is the underlay; the virtual Layer 2 space running across VTEPs is the overlay.
Point-to-Point vs. Multicast vs. Unicast FDB
Data centers deploy BGP EVPN control planes or IGMP snooping to locate remote VTEPs automatically. In multi-cloud setups, this fails immediately: public cloud providers drop multicast traffic at the hypervisor level. For small deployments of 2 to 10 nodes, static point-to-point tunnels or statically populated Forwarding Database (FDB) tables offer the most dependable design.
Hands-on Practice: Step-by-Step VXLAN Setup
We will configure a point-to-point tunnel between two Debian/Ubuntu servers across different cloud providers:
- Server 1 (AWS EC2): Public underlay
198.51.100.10, Overlay IP10.200.0.1/24 - Server 2 (Hetzner Cloud): Public underlay
203.0.113.20, Overlay IP10.200.0.2/24
We will assign VNI 100 to the interface and use standard IANA port 4789.
Step 1: Verify the Kernel Module and Firewall Access
Verify that the Linux kernel has the VXLAN module loaded on both servers:
sudo modprobe vxlan
lsmod | grep vxlan
Linux kernels prior to version 3.12 defaulted to UDP port 8472. Always specify destination port 4789 explicitly to match RFC 7348 standards.
Next, permit UDP traffic on port 4789 between hosts. On Server 1 using UFW:
sudo ufw allow proto udp from 203.0.113.20 to 198.51.100.10 port 4789 comment 'VXLAN tunnel'
Step 2: Configure the VTEP on Server 1
Create the virtual interface named vxlan100 with ip link:
sudo ip link add vxlan100 type vxlan \
id 100 \
dstport 4789 \
local 198.51.100.10 \
remote 203.0.113.20 \
dev eth0
Assign our private overlay IP address and bring the interface online:
sudo ip addr add 10.200.0.1/24 dev vxlan100
sudo ip link set up dev vxlan100
Step 3: Configure the VTEP on Server 2
Run the matching configuration on Server 2, reversing the local and remote addresses:
sudo ip link add vxlan100 type vxlan \
id 100 \
dstport 4789 \
local 203.0.113.20 \
remote 198.51.100.10 \
dev eth0
sudo ip addr add 10.200.0.2/24 dev vxlan100
sudo ip link set up dev vxlan100
Step 4: Verify Connectivity and Inspect Frames
Ping Server 2 from Server 1 across the tunnel:
ping -c 3 10.200.0.2
Confirm the encapsulation format by monitoring Server 1’s physical interface in a second terminal:
sudo tcpdump -nni eth0 udp port 4789
You will see standard IPv4 UDP packets on port 4789 carrying the inner ICMP echo payloads:
14:22:01.104218 IP 198.51.100.10.54321 > 203.0.113.20.4789: VXLAN, flags [I] (0x08), vni 100
IP 10.200.0.1 > 10.200.0.2: ICMP echo request, id 412, seq 1, length 64
Step 5: Account for MTU Overhead
MTU mismatches are the most frequent source of broken tunnel connections. ICMP pings will succeed, but large HTTP requests or SSH sessions will hang mysteriously during the TLS handshake.
VXLAN encapsulation adds a fixed 50-byte header footprint over IPv4:
- Outer Ethernet Frame: 14 bytes
- Outer IPv4 Header: 20 bytes
- Outer UDP Header: 8 bytes
- VXLAN Header: 8 bytes
On a standard underlay network with an MTU of 1500 bytes, clamp the overlay interface MTU to 1450 bytes (1500 – 50). If your underlay uses IPv6, reduce it to 1430 bytes to accommodate the larger 40-byte outer IP header:
sudo ip link set dev vxlan100 mtu 1450
Step 6: Make Settings Persistent Across Reboots
Interface configurations built with raw ip commands vanish after rebooting. For systems using Netplan (Ubuntu 20.04+), persist this interface in /etc/netplan/99-vxlan.yaml:
network:
version: 2
tunnels:
vxlan100:
mode: vxlan
id: 100
link: eth0
local: 198.51.100.10
remote: 203.0.113.20
port: 4789
addresses:
- 10.200.0.1/24
mtu: 1450
Test and apply the changes cleanly:
sudo netplan generate
sudo netplan apply
Production Recommendations
Running raw overlay links over public networks introduces operational challenges that require careful planning:
- Add WireGuard for Encryption: Native VXLAN sends all internal traffic in plaintext. For data crossing public transit, bind the VXLAN interface directly over an underlying WireGuard tunnel (e.g.,
dev wg0) rather than exposing port 4789 publicly. - Query the Forwarding Database: When scaling beyond two static endpoints, examine how your host learns MAC addresses. Inspect active entries with
bridge fdb show dev vxlan100to identify stale routes and avoid broadcast flooding. - Bridge VM and Container Workloads: To place Docker containers or KVM guests on the overlay, attach
vxlan100to a local Linux bridge (br0). Container veth pairs joined tobr0can then communicate across clouds without host-level port forwarding.
Key Takeaways
The Linux kernel’s built-in iproute2 tooling delivers resilient cross-cloud networking without the resource overhead of enterprise SDN stacks. Configuring your endpoints deliberately, enforcing a 1450 MTU floor, and restricting UDP port 4789 gives you a predictable Layer 2 fabric across disparate hosting providers.
