Course contentsShow
← Linux
Lesson 1128 of 1,81910. Network Administration and Kernel StacksFree lesson

VXLAN Encapsulation for Overlays

Extend Layer 2 networks over Layer 3 infrastructures using VXLAN.

In this lesson, you will learn how to use VXLAN to stretch a Layer 2 Ethernet segment across a Layer 3 routed network.

The Problem: The Layer 2 Limit

In standard networking, Layer 2 segments (VLANs) are restricted by the broadcast domain. If you need two servers to be on the same "virtual wire" but they exist in different subnets or across different data centers, traditional bridging fails. We need a way to encapsulate Ethernet frames inside IP packets so they can traverse standard routers.

How VXLAN Works

VXLAN (Virtual Extensible LAN) acts like a "tunnel" that encapsulates a Layer 2 Ethernet frame inside a standard UDP/IP packet. The physical network (the Underlay) only sees the outer IP header, while the virtual machines (the Overlay) see their original Ethernet frames.

Unlike GRE, which we discussed previously, VXLAN uses a 24-bit identifier called a VNI (VXLAN Network Identifier). This allows for up to 16 million unique virtual networks, far surpassing the 4,094 limit of standard 802.1Q VLANs.

Implementation Example

In Linux, you create a VXLAN interface that acts as a virtual tunnel endpoint (VTEP). You define the underlay multicast group or remote destination and the VNI.

# Create a VXLAN interface named 'vxlan0'
# VNI 100, remote destination 192.168.1.50, dstport 4789
ip link add vxlan0 type vxlan id 100 remote 192.168.1.50 dstport 4789 dev eth0

# Bring the interface up and bridge it to your local network
ip link set vxlan0 up
brctl addif br0 vxlan0

When a frame is sent to the vxlan0 interface, the Linux kernel wraps the frame in a UDP header (typically destination port 4789), adds an IP header with the destination VTEP IP, and forwards it out the physical interface (eth0). The receiving VTEP strips the outer headers and delivers the original frame to the local bridge. This effectively creates a massive, distributed virtual switch across your entire Layer 3 infrastructure.

Key Takeaway: VXLAN enables massive multi-tenancy and L2 connectivity over L3 routed fabrics by encapsulating Ethernet frames within UDP packets using a 24-bit VNI.