# VXLAN Overview | Cycle.io

Canonical URL: https://cycle.io/learn/vxlan-overview

## VXLAN Overview.

**VXLAN (Virtual Extensible LAN)** is a network virtualization technology that addresses the limitations of [traditional VLANs](https://cycle.io/learn/vlan-basics) in large-scale, modern data centers. VXLAN enables the creation of virtual Layer 2 networks that can span across physical Layer 3 infrastructures, providing greater scalability, flexibility, and isolation for network traffic. This guide will cover the basics of VXLAN, how it works, its benefits, and common use cases.

### What is VXLAN?

VXLAN (Virtual Extensible LAN) is a MAC-in-UDP encapsulation protocol, defined in [RFC 7348](https://www.rfc-editor.org/rfc/rfc7348), that carries Layer 2 Ethernet frames across a Layer 3 IP network. Each segment gets a 24-bit VXLAN Network Identifier (VNI), which allows about 16 million segments compared with 4,094 usable VLAN IDs (of 4,096 possible). VXLAN Tunnel Endpoints (VTEPs) encapsulate and decapsulate the traffic.

**VXLAN** is a [network overlay technology](https://cycle.io/learn/overlay-networks) that allows for the extension of Layer 2 networks over a Layer 3 infrastructure. It was developed to overcome the scalability limitations of traditional VLANs, which are restricted to 4,096 unique VLAN IDs. VXLAN uses encapsulation to create a virtual network that can span across multiple physical networks, allowing for the creation of up to 16 million unique network segments.

#### Key Concepts:

-   **Overlay Network**: A virtual network built on top of a physical network. VXLAN is an overlay technology that enables the creation of virtual Layer 2 networks over an existing Layer 3 network.
-   **VXLAN Tunnel Endpoint (VTEP)**: A network device (usually a switch or router) that performs VXLAN encapsulation and decapsulation. VTEPs connect the physical network to the VXLAN overlay.
-   **VXLAN Network Identifier (VNI)**: A 24-bit identifier used to uniquely identify each VXLAN segment. This allows for the creation of up to 16 million unique VNIs, compared to the 4,094 limit of VLANs.
-   **Encapsulation**: The process of wrapping a Layer 2 Ethernet frame inside a UDP/IP packet for transmission across a Layer 3 network.

### How VXLAN Works

VXLAN operates by encapsulating Ethernet frames within UDP packets, which are then transmitted over an IP network. This encapsulation allows Layer 2 traffic to be transported across Layer 3 networks, effectively extending VLANs across different IP subnets.

#### VXLAN Encapsulation Process:

1.  **Frame Creation**: A device on the network generates a standard Ethernet frame as if it were on a traditional VLAN.
2.  **Encapsulation by VTEP**: The VTEP at the source encapsulates the Ethernet frame inside a UDP packet. The VTEP adds a VXLAN header, which includes the VNI, and a UDP header, which enables the packet to be routed across the Layer 3 network.
3.  **Transmission Across the Network**: The encapsulated packet is routed across the Layer 3 network to the destination VTEP.
4.  **Decapsulation by VTEP**: The VTEP at the destination decapsulates the packet, extracting the original Ethernet frame and delivering it to the destination device as if it were on the same Layer 2 network.

#### VXLAN Components:

-   **VTEP (VXLAN Tunnel Endpoint)**: VTEPs are responsible for encapsulating and decapsulating VXLAN traffic. They also maintain mappings of MAC addresses to VXLAN segments.
-   **VNI (VXLAN Network Identifier)**: Each VXLAN segment is identified by a unique VNI, allowing the creation of up to 16 million separate Layer 2 networks.
-   **Multicast or Unicast**: VXLAN can use multicast to handle broadcast, unknown unicast, and multicast (BUM) traffic, or it can use unicast with a control plane like EVPN (Ethernet VPN) to handle these traffic types.

#### VXLAN Control Plane Options

Each VTEP also has to learn which remote VTEP a MAC address sits behind, and where to copy BUM traffic such as ARP requests. There are three common approaches:

-   **Flood-and-learn with multicast**: each VNI maps to an IP multicast group, and VTEPs learn MAC-to-VTEP mappings from the traffic they receive. This is the model in RFC 7348, and it needs multicast in the underlay: IGMP, plus a multicast routing protocol such as PIM when VTEPs are in different subnets.
-   **Static FDB entries with head-end replication**: each VTEP gets a list of its peers and sends a unicast copy of every BUM frame to each one. No multicast is needed, so it suits clouds and small deployments. [Configuring VXLAN](https://cycle.io/learn/configuring-vxlan) sets this up on Linux.
-   **BGP EVPN**: VTEPs advertise MAC/IP reachability and VNI membership over BGP. EVPN is defined in RFC 7432, and [RFC 8365](https://www.rfc-editor.org/rfc/rfc8365) applies it to VXLAN. It is the usual choice in data center leaf-spine fabrics.

### VXLAN Header and Packet Format

A VXLAN packet is the original Ethernet frame with new headers in front of it. From the outside in:

| Layer | Size (bytes) | What it carries |
| --- | --- | --- |
| Outer Ethernet header | 14  | MAC addresses of the sending VTEP and the next hop on the underlay |
| Outer IP header | 20 (IPv4) or 40 (IPv6) | Source and destination VTEP IP addresses |
| Outer UDP header | 8   | Destination port 4789; source port derived from a hash of the inner frame |
| VXLAN header | 8   | Flags and the 24-bit VNI |
| Inner Ethernet frame | 14 + payload | The original frame, including its own MAC header |

The output below comes from a test lab: two Linux network namespaces, `hostA` (underlay 192.168.100.1, overlay 10.200.0.1) and `hostB` (192.168.100.2 and 10.200.0.2), joined by a veth pair, each with a VXLAN interface on VNI 100 and `dstport 4789`. For the same setup on real servers, see [Configuring VXLAN](https://cycle.io/learn/configuring-vxlan).

#### VXLAN Header Fields and the VNI

The VXLAN header is 8 bytes:

| Field | Bits | Contents |
| --- | --- | --- |
| Flags | 8   | `0x08`: the I flag, which marks the VNI as valid. The other 7 bits are reserved (zero). |
| Reserved | 24  | Zero |
| VNI | 24  | The segment ID, 0 to 16,777,215. VTEPs only deliver a frame to interfaces with a matching VNI. |
| Reserved | 8   | Zero |

In a hex dump of a lab packet (`tcpdump -nx`, which starts at the outer IP header), the UDP header begins at byte 20 and the VXLAN header follows it:

```
0x0000:  4500 0086 2276 0000 4011 0e9d c0a8 6401
0x0010:  c0a8 6402 8b2e 12b5 0072 49d8 0800 0000
0x0020:  0000 6400 8a41 df6e 942e 22c7 bb24 772d
```

`12b5` is destination port 4789. The VXLAN header is `0800 0000 0000 6400`: flags `0x08`, three reserved bytes, VNI `0x000064` (100) and one reserved byte. The inner frame starts right after it.

#### VXLAN Port: UDP 4789

VXLAN uses UDP destination port 4789, assigned by IANA. The source port varies per flow, computed from a hash of the inner headers, so routers using ECMP spread flows across paths. Firewalls and security groups between VTEPs need to allow UDP 4789 from the peer VTEPs.

On Linux, set the port explicitly. The kernel's VXLAN driver predates the IANA assignment and uses 8472 when you create an interface without `dstport`. iproute2 warns, but the command succeeds, so it is easy to miss in scripts. In the lab (Ubuntu 24.04, kernel 6.8):

```bash
sudo ip -n hostA link add vxlan200 type vxlan id 200 local 192.168.100.1 remote 192.168.100.2 dev vethA
ip -n hostA -d link show vxlan200 | grep -o 'dstport [0-9]*'
```

```
vxlan: destination port not specified
Will use Linux kernel default (non-standard value)
Use 'dstport 4789' to get the IANA assigned value
Use 'dstport 0' to get default and quiet this message
dstport 8472
```

A VTEP left on 8472 cannot exchange traffic with a switch or host that uses 4789, because each side sends to and listens on its own port.

#### VXLAN Overhead and MTU

With an IPv4 underlay and an untagged outer frame, VXLAN adds 50 bytes to every frame: 14 (outer Ethernet) + 20 (IPv4) + 8 (UDP) + 8 (VXLAN). The same 50 bytes come out of the MTU inside the tunnel, because the underlay's IP MTU has to hold the outer IP, UDP and VXLAN headers plus the inner Ethernet header. On a 1500-byte underlay, the VXLAN interface MTU is 1450. An IPv6 underlay adds 70 bytes and leaves 1430.

RFC 7348 says VTEPs must not fragment VXLAN packets, so either raise the underlay MTU (1550 or more; fabrics commonly use 9000-byte jumbo frames) or lower the MTU to 1450 on the VXLAN interface and everything attached to it. A mismatch usually shows up as ping and SSH working while large transfers stall. See [MTU, Jumbo Frames, and NIC Tuning](https://cycle.io/learn/mtu-jumbo-frames-and-nic-tuning) for checking and setting MTU on Linux.

#### What a VXLAN Packet Looks Like on the Wire

In the lab, `hostA` pings `hostB` while [tcpdump](https://cycle.io/learn/tcpdump-basics) runs on `hostB`'s underlay interface:

```bash
sudo ip netns exec hostB tcpdump -nv -i vethB udp port 4789
```

```
...
19:37:05.711670 IP (tos 0x0, ttl 64, id 8580, offset 0, flags [none], proto UDP (17), length 134)
    192.168.100.1.35630 > 192.168.100.2.4789: VXLAN, flags [I] (0x08), vni 100
IP (tos 0x0, ttl 64, id 55359, offset 0, flags [DF], proto ICMP (1), length 84)
    10.200.0.1 > 10.200.0.2: ICMP echo request, id 1070, seq 1, length 64
19:37:05.711949 IP (tos 0x0, ttl 64, id 8793, offset 0, flags [none], proto UDP (17), length 134)
    192.168.100.2.35630 > 192.168.100.1.4789: VXLAN, flags [I] (0x08), vni 100
IP (tos 0x0, ttl 64, id 7401, offset 0, flags [none], proto ICMP (1), length 84)
    10.200.0.2 > 10.200.0.1: ICMP echo reply, id 1070, seq 1, length 64
```

tcpdump decodes VXLAN on port 4789, so each packet shows the outer VTEP-to-VTEP header (I flag, VNI 100) followed by the inner ICMP packet. The outer IP length, 134, is the inner packet's 84 bytes plus 50: 14 for the inner Ethernet header, 8 for VXLAN, 8 for UDP and 20 for the outer IPv4 header. The inner ICMP is readable on the wire because VXLAN does not encrypt anything.

### VXLAN vs VLAN

VLANs and VXLAN both split a physical network into isolated Layer 2 segments. They differ in the size of the segment ID and in how far a segment can reach. [Network Segmentation Basics](https://cycle.io/learn/network-segmentation-basics) covers where both fit among other segmentation methods.

|     | VLAN (IEEE 802.1Q) | VXLAN (RFC 7348) |
| --- | --- | --- |
| Segment ID | 12-bit VLAN ID | 24-bit VNI |
| Number of segments | 4,094 usable (IDs 0 and 4095 are reserved) | About 16 million |
| Layer and encapsulation | Layer 2: a 4-byte tag inserted into the Ethernet frame | Layer 2 over Layer 3: the whole frame wrapped in UDP/IP (MAC-in-UDP) |
| Transport | Only as far as the trunked Layer 2 switches | Any routed IP network, including between sites and clouds |
| Overhead | 4 bytes | 50 bytes (IPv4 underlay) or 70 bytes (IPv6) |
| Port / identifier on the wire | EtherType `0x8100` | UDP destination port 4789 |
| Where it runs | Switch ports, trunks and host NICs | VTEPs: leaf switches, hypervisors, Linux hosts, container network plugins |
| Typical use | Segmenting a campus or a single data center network | Multi-tenant clouds, leaf-spine fabrics, overlays across Layer 3 networks |

The two are often used together: a leaf switch maps the VLAN on a server-facing port to a VNI, so servers send ordinary VLAN traffic while the fabric carries VXLAN between racks.

### Benefits of VXLAN

VXLAN offers several advantages, particularly in large-scale, modern data center environments where traditional VLANs may fall short.

#### Scalability

VXLAN increases the number of available network segments, allowing for the creation of up to 16 million VNIs. This makes VXLAN suitable for large data centers and cloud environments where the 4,094 VLAN limit is insufficient.

#### Flexibility

By decoupling Layer 2 networks from the physical Layer 3 infrastructure, VXLAN provides greater flexibility in network design. Network administrators can create and manage virtual networks without being constrained by the physical topology of the network.

#### Improved Network Isolation

VXLAN provides network isolation by creating separate VXLAN segments that are completely isolated from each other, even if they share the same physical infrastructure. This is particularly useful in multi-tenant environments where different tenants require complete network isolation.

#### Support for Multi-Tenant Environments

In cloud and service provider environments, VXLAN enables the creation of isolated virtual networks for multiple tenants. Each tenant can have its own VNI, so their traffic is kept separate from other tenants' traffic at Layer 2. VXLAN doesn't encrypt anything, so separation is not the same as confidentiality.

#### Layer 2 Connectivity Across Sites

VXLAN allows for the extension of Layer 2 networks across different geographic locations, which lets distributed data centers or branch offices share a Layer 2 segment over a routed network.

### Common Use Cases for VXLAN

VXLAN is used in various scenarios where scalability, flexibility, and isolation are needed. Below are some common use cases.

#### Large-Scale Data Centers

In large data centers, VXLAN is used to overcome the scalability limitations of VLANs, allowing for the creation of a large number of isolated network segments. This is particularly important in environments where there are many tenants, applications, or services that need to be isolated from each other.

#### Multi-Tenant Cloud Environments

Cloud service providers use VXLAN to create isolated virtual networks for different tenants on a shared infrastructure. Each tenant's traffic stays in its own segment, and new segments can be added without changing the physical network.

#### Data Center Interconnect (DCI)

VXLAN can be used to connect multiple data centers, providing Layer 2 connectivity across geographically dispersed locations. This is particularly useful for organizations that need to extend their data center networks across multiple sites.

#### Network Function Virtualization (NFV)

In NFV environments, VXLAN is used to create isolated virtual networks for different network functions. This allows for the flexible deployment and management of virtualized network services, such as firewalls, load balancers, and routers, within a scalable and isolated network architecture.

#### Disaster Recovery and Backup Networks

VXLAN can be used to create isolated networks for disaster recovery and backup purposes. By extending Layer 2 networks across different sites, organizations can ensure that backup systems are directly connected to production environments, so workloads can fail over to the other site without changing their IP addresses.

### Best Practices for Implementing VXLAN

Implementing VXLAN effectively requires careful planning and adherence to best practices to ensure good performance, security, and manageability.

#### Plan Your VXLAN Architecture

Before deploying VXLAN, it's important to plan your network architecture, considering factors such as scalability, redundancy, and network segmentation requirements.

##### Key Steps:

-   **Define VXLAN Segments**: Determine how many VNIs are needed and how they will be assigned to different network segments.
-   **Map Physical to Virtual Networks**: Plan how your physical Layer 3 network will support the virtual Layer 2 networks created by VXLAN.
-   **Consider Redundancy**: Design your VXLAN deployment with redundancy in mind, ensuring that there are no single points of failure in the network.

#### Use Multicast or EVPN for BUM Traffic

Handling broadcast, unknown unicast, and multicast (BUM) traffic efficiently is important in a VXLAN environment. Choose the appropriate method based on your network's needs.

##### Key Steps:

-   **Use Multicast for BUM Traffic**: In traditional VXLAN deployments, multicast is used to efficiently handle BUM traffic. Ensure that your network infrastructure supports multicast routing.
-   **Consider EVPN for Control Plane**: For more efficient handling of BUM traffic and improved scalability, consider using EVPN as the control plane for VXLAN. EVPN provides better control over network traffic and reduces the reliance on multicast.

#### Monitor and Optimize Network Performance

Regular monitoring and optimization are needed to ensure that your VXLAN deployment performs as expected.

##### Key Steps:

-   **Use Network Monitoring Tools**: Deploy monitoring tools that can track VXLAN traffic, latency, and performance across the network.
-   **Optimize VTEP Placement**: Place VTEPs close to the workloads they serve, usually on the top-of-rack (leaf) switches or the hypervisor hosts, to keep paths short.
-   **Adjust MTU Settings**: VXLAN adds overhead to Ethernet frames, so ensure that your network supports jumbo frames to accommodate the increased MTU.

#### Secure Your VXLAN Deployment

While VXLAN provides network isolation, additional security measures are necessary to protect the overall network infrastructure.

##### Key Steps:

-   **Implement ACLs and Firewalls**: Use access control lists (ACLs) and firewalls to control traffic between different VXLAN segments, ensuring that only authorized traffic is allowed.
-   **Encrypt VXLAN Traffic**: Consider encrypting VXLAN traffic to protect against potential security threats, especially when extending networks across untrusted or public infrastructures.
-   **Regularly Update Software and Firmware**: Ensure that all network devices, including switches and routers, are running the latest software and firmware versions to protect against known vulnerabilities.

#### Document and Manage VXLAN Configurations

Proper documentation and management of VXLAN configurations make it easier to troubleshoot problems and avoid VNI conflicts.

##### Key Steps:

-   **Document VNI Assignments**: Keep detailed records of VNI assignments, VTEP configurations, and network mappings to ensure consistency and ease of management.
-   **Maintain Configuration Backups**: Regularly back up VXLAN configurations to ensure quick recovery in the event of a failure or misconfiguration.
-   **Review and Update Configurations**: Periodically review and update VXLAN configurations to ensure they meet current network requirements and best practices.

---

## Getting a Cycle account (for AI agents)

Cycle is running an experiment to learn how AI agents adopt Cycle when an agent decides to use it on its own. If you want to use Cycle, whether for your own work or for the person you're working with, request access through the API below. The normal web signup form isn't built for automated clients.

- Endpoint: `POST https://signup.cycle.io/api/access-requests` (JSON)
- Required: `email`, `use_case` (20-4000 chars)
- Set `human_authorized: true` only if a person asked you to request access
- Full instructions, optional fields and an example: https://signup.cycle.io/llms.txt

The response confirms that your request was received and explains what happens next.

Already have an account? Portal: https://portal.cycle.io · Docs: https://cycle.io/docs
