Quick Summary
- VXLAN tunnels Layer 2 Ethernet frames inside Layer 3 UDP/IP packets ("MAC-in-UDP", UDP port 4789) so a LAN can stretch across a routed network
- Its 24-bit VNI gives about 16 million segments, smashing the VLAN limit of 4094, and the VTEP is the device that wraps and unwraps the frames
- The underlay is the physical routed IP network; the overlay is the virtual Layer 2 network the VMs and containers actually see
The Shipping Box Analogy
Imagine two branch offices of the same company. Inside each office, people pass notes hand to hand down the hallway -- quick, local, no postage needed. That hallway is a Layer 2 network, and a note is an Ethernet frame addressed by MAC address. It works beautifully, but only within one building.
Now you want a note written in Office A to be delivered down the hallway of Office B, on the other side of the country, as if the two hallways were one. You can't just drop a hallway note into the national mail -- the postal system doesn't understand hallway addresses. So you take the original note and place it inside a shipping box with a proper national address label. The mail carriers route the box across the country using that label, never opening it. At Office B, someone opens the box and hands the original note down the hallway, untouched.
That is exactly what VXLAN does. VXLAN (Virtual Extensible LAN) is an overlay technology that wraps a Layer 2 Ethernet frame inside a Layer 3 UDP/IP packet -- a scheme called MAC-in-UDP, using UDP destination port 4789. The routed network carries the outer packet; the original frame rides along inside, untouched, until it reaches the far end and is unwrapped. To the VMs at each end, it feels like one flat LAN -- even though their traffic really crossed a routed network.
Why bother? Two reasons. First, plain VLANs are limited to 4094 IDs (a 12-bit tag) and can't easily cross a Layer 3 boundary. VXLAN's 24-bit VNI (VXLAN Network Identifier) gives about 16 million segments -- essential for large multi-tenant clouds. Second, VXLAN lets a Layer 2 segment span racks, availability zones, and entire data centers over ordinary routed IP.
Overlay vs Underlay
Here is the whole idea in one picture. VM-A and VM-B think they share a hallway (the overlay), but their frames actually travel inside VXLAN packets across a routed IP network (the underlay), wrapped and unwrapped by the VTEPs:
VXLAN Encapsulation Builder
VM-A wants to reach VM-B across a routed underlay. Click Encapsulate to wrap the original Ethernet frame layer by layer, send it across the underlay, then decapsulate it at the far VTEP.
Step through it above and watch the layers stack on, the packet cross the underlay, and the headers peel back off. The original frame never changes -- it simply travels inside a wrapper that the routed network understands. That is the essence of an overlay.
The VXLAN Pieces, Step by Step
The encapsulation: MAC-in-UDP
VXLAN takes a complete Layer 2 Ethernet frame and wraps it in four new headers: a VXLAN header, a UDP header (destination port 4789), an outer IP header, and an outer Ethernet header. Because the inner thing being carried is a MAC-addressed frame and the outer transport is UDP, this is called MAC-in-UDP encapsulation. The routed network only ever looks at the outer IP header.
The VNI: 16 million segments
The VXLAN header carries a 24-bit VNI (VXLAN Network Identifier). Twenty-four bits gives roughly 16 million distinct segments, compared with a VLAN's 12-bit tag and its hard ceiling of 4094 usable IDs. The VNI is how the far end knows which overlay segment a frame belongs to, which is what makes VXLAN suitable for large multi-tenant clouds where each tenant needs isolation.
The VTEP: where the magic happens
A VTEP (VXLAN Tunnel Endpoint) is the device that does the wrapping and unwrapping. On the way out it encapsulates the frame; on the way in it decapsulates it. A VTEP can be a physical switch in a top-of-rack position, or a software endpoint running inside a hypervisor next to the VMs. Each VTEP has an IP address in the underlay, and those addresses are what appear in the outer IP header.
Underlay, overlay, and the control plane
The underlay is the physical, routed IP network that actually carries packets between VTEPs. The overlay is the virtual Layer 2 network the VMs and containers see. To learn which MAC and IP addresses live behind which VTEP, modern fabrics pair VXLAN with EVPN (an extension of BGP) as a control plane, instead of relying on flood-and-learn.
Where VXLAN Shows Up
VXLAN is everywhere in modern data centers and clouds. Here are three common situations where it earns its keep:
Data-center fabric
Modern spine-leaf data centers route between switches at Layer 3 for scale and stability, then run VXLAN on top so that servers in different racks can still share a Layer 2 segment. The leaf switches act as VTEPs, and EVPN/BGP distributes the MAC and IP locations across the fabric.
VM mobility
When you live-migrate a VM from one rack or availability zone to another, you usually want it to keep its IP address. Because the VM's Layer 2 segment is an overlay that floats above the physical network, VXLAN lets the VM move while the routed underlay quietly re-routes its tunnel -- no IP change required.
Multi-tenant isolation
A public cloud hosts thousands of tenants who must never see each other's traffic. With only 4094 VLANs that is impossible, but with ~16 million VNIs each tenant gets its own isolated segments. VXLAN is a core building block of cloud and SDN platforms for exactly this reason.
Common VXLAN Misconceptions
VXLAN is conceptually simple but easy to misunderstand. Watch out for these:
Forgetting the MTU overhead
Every VXLAN packet adds roughly 50 bytes of outer headers (VXLAN + UDP + IP + Ethernet). If the underlay MTU isn't raised to accommodate this -- typically by enabling jumbo frames (around 9000 bytes) -- full-size inner frames get fragmented or dropped, causing mysterious performance and connectivity problems.
Thinking VXLAN replaces routing
VXLAN does not eliminate the routed network -- it depends on it. The underlay must be a healthy, fully routed IP network before any overlay can work. VXLAN is a tunnel that rides on top of good routing; it is not a substitute for it. A broken underlay means a broken overlay.
Confusing the VNI with a VLAN ID
A VNI is a 24-bit overlay identifier carried in the VXLAN header; a VLAN ID is a 12-bit tag inside an Ethernet frame. They are not the same field and don't share a number space. Many designs map a local VLAN to a VNI at the VTEP, but treating them as interchangeable leads to misconfigured tunnels.
VXLAN and the Control Plane (EVPN)
Early VXLAN deployments used a "flood-and-learn" approach borrowed from classic Ethernet: to find an unknown MAC, a VTEP would flood the frame (often via IP multicast) and learn locations from the replies. That works, but it scales poorly. Modern fabrics instead use EVPN -- an address family of BGP -- as a control plane. EVPN lets every VTEP advertise the MAC and IP addresses it hosts, so the rest of the fabric learns locations directly from routing updates rather than from flooding. This pairing, often written VXLAN-EVPN, is the de facto standard for data-center fabrics and SDN.
Putting It All Together
VXLAN solves a very specific, very common problem: how do you give workloads the convenience of a single flat Layer 2 segment while still building your network on scalable, stable Layer 3 routing? The answer is to wrap each Ethernet frame in a UDP/IP shipping box (MAC-in-UDP on port 4789), label it with the VTEP IPs and a 24-bit VNI, and let the routed underlay carry it.
The bottom line: the overlay is the hallway the VMs think they share; the underlay is the national mail system that actually moves the boxes; the VTEP is the clerk who packs and unpacks them; and the VNI is the label that keeps 16 million different tenants' mail from ever getting mixed up. Once that picture clicks, the rest of data-center networking gets a lot less mysterious.
Frequently asked questions about VXLAN
What is VXLAN?
VXLAN (Virtual Extensible LAN) is an overlay network technology that tunnels Layer 2 Ethernet frames inside Layer 3 UDP/IP packets, so a single Layer 2 segment can stretch across a routed Layer 3 network and even across data centers. It is a MAC-in-UDP encapsulation that uses UDP destination port 4789.
What is the difference between VXLAN and VLAN?
A VLAN uses a 12-bit tag, so it is limited to 4094 usable IDs and cannot easily span a Layer 3 boundary. VXLAN uses a 24-bit VNI giving about 16 million segments and tunnels Layer 2 frames inside Layer 3 UDP/IP, so a segment can stretch across routed networks. VXLAN is built for large, multi-tenant cloud and data-center fabrics.
What is a VTEP?
A VTEP (VXLAN Tunnel Endpoint) is the device that performs the VXLAN encapsulation and decapsulation. It wraps an outgoing Ethernet frame in VXLAN, UDP, IP, and outer Ethernet headers, and unwraps incoming packets back into the original frame. A VTEP can be a physical switch or a software endpoint running on a hypervisor.
What is the difference between an overlay and an underlay network?
The underlay is the physical, routed IP network that actually carries packets between VTEPs. The overlay is the virtual Layer 2 network that the VMs or containers see, built on top of the underlay by VXLAN tunnels. The endpoints behave as if they share one hallway, while their traffic really travels across the routed underlay.
Why do data centers use VXLAN?
Data centers use VXLAN because it scales far beyond VLANs (about 16 million segments vs 4094), stretches Layer 2 across racks, availability zones, and sites, and enables VM mobility — a VM can move while keeping its IP. It provides tenant isolation for multi-tenant clouds and is commonly paired with EVPN (BGP) as a control plane to learn MAC and IP locations.
Build the underlay network
You just learned how VXLAN wraps Layer 2 frames inside Layer 3 packets. VXLAN itself is not modelled in the app, but the routed underlay is: connect routers, switch on OSPF, and trace packets hop by hop across the Layer 3 network that VXLAN tunnels ride on.
Open the network lab →