Marcio Cunha

VXLAN: How to Build Virtual Networks That Span Multiple Data Centers

Learn how VXLAN technology encapsulates network packets to extend the data link layer over IP, unifying geographically dispersed data centers efficiently.

Marcio Cunha14 min
Also available in:EspañolPortuguês
Summary
  • MAC-in-UDP encapsulation adds a 50-byte overhead that requires MTU adjustments across the underlying physical infrastructure.
  • The technology eliminates traditional VLAN limitations by supporting up to 16 million logical segments on the same network.
  • BGP EVPN control planes automate MAC address learning and dramatically reduce unnecessary broadcast traffic.
  • Extended L2 connectivity simplifies virtual machine migrations without breaking sessions or requiring IP reallocations.
  • Proper MTU planning and Layer 4 load balancing design prevent packet fragmentation failures in multi-site environments.

The challenge of connecting digital islands

Imagine your company has grown to the point where a single data center, the physical location housing hundreds of computers and servers processing data, is no longer enough. You rent space in another building in a neighboring city or even another country to ensure redundancy and proximity to new customers. In theory, everything should talk as if it were in the same room. In practice, you run into a historical computing barrier: traditional local networks were not built to easily span wide geographic distances. This is precisely where VXLAN comes into play.

Historically, networks used VLANs (Virtual Local Area Networks), which act like partitions in a giant office, separating the finance department's traffic from HR. The problem is that the technical limit for VLANs is only 4,096 identifiers, a number that quickly evaporates in cloud computing environments. Furthermore, trying to extend a VLAN via fiber optics between two distant buildings creates a nightmare of instability and packet loss due to latency and broadcast traffic, which suffocates cables with unnecessary messages.

What is VXLAN and how encapsulation magic works

VXLAN (Virtual Extensible LAN) solves this Gordian knot by using an ingenious trick called encapsulation. In network engineering, encapsulation means putting a data packet inside another, like putting an important letter inside a reinforced box before mailing it through regular post. When a server inside data center A wants to talk to a server in data center B, VXLAN takes the original Ethernet packet, the standard computers understand, and wraps it with a UDP header, the same simple and fast technology used for video streaming and online gaming.

This process transforms the data link layer, known as Layer 2, into Layer 3 IP packets that travel freely across the public internet or corporate private networks. In simple terms, VXLAN builds an invisible tunnel on top of the network you already own. For the servers at the ends, it is as if they were plugged into the same network switch, the central device connecting computers on a local network, even though they are separated by thousands of miles of ocean or continent.

The mathematics of tunnels and packet size impact

All this flexibility comes with a direct operational cost to the infrastructure: overhead, which is the extra space occupied by the additional headers that VXLAN injects into data. A standard VXLAN packet adds about 50 extra bytes of control information to every message sent. If your physical network is configured with the traditional MTU (Maximum Transmission Unit) limit of 1,500 bytes, these large packets will need to be chopped up along the way, severely dropping application performance.

To circumvent this trap, network engineers must configure what we call Jumbo Frames across the entire intermediate physical infrastructure, raising the MTU to 9,000 bytes or, at the very least, adjusting the maximum segment size at the endpoints. In practice, this means that switches and routers along the path must be prepared to handle fatter packets without choking. Ignoring this detail during the design phase is the recipe for slow systems and mysterious connection drops during peak hours.

BGP EVPN: the intelligent brain guiding traffic

In the early adoption of VXLAN, tunnels relied on flood-and-learn methods based on trial and error, much like office gossip: when a server wanted to find another, it shouted to the entire network asking who had a specific MAC address, generating colossal noise. With architectural maturity, the industry adopted BGP EVPN (Border Gateway Protocol Ethernet VPN), an advanced routing protocol that acts as a centralized and intelligent directory for all virtual networks.

BGP EVPN acts like a synchronized registry among different data centers. Each edge switch constantly advertises which virtual machines and MAC addresses are connected to its local ports. When a machine wants to talk to another in the other building, the switch does not need to ask the entire network; it checks its internal table updated by EVPN and sends the packet directly to the correct VXLAN tunnel. This drastically reduces useless broadcast traffic and allows the network to scale to thousands of servers without performance degradation.

Practical multi-site design and operational considerations

Implementing VXLAN across multiple data centers requires rigor in planning redundancy and resilience. Since tunnels rely on the underlying IP infrastructure, any instability in the primary routing instantly affects all extended virtual networks. Therefore, it is critical to design redundant network paths using robust dynamic routing protocols, ensuring that if a primary fiber optic cable is accidentally cut by an excavator, traffic migrates to an alternative path in milliseconds.

Another critical point is observability. Debugging issues in a VXLAN network requires tools that can see both the inner packet and the outer UDP encapsulation. Traditional monitoring tools based solely on simple ping can mask packet losses occurring specifically inside the tunnels. Adopting advanced telemetry and traffic flow collectors ensures the engineering team identifies bandwidth bottlenecks or configuration flaws before they impact end users.

Conclusion

VXLAN has revolutionized how we view IT infrastructure, transforming isolated data centers into a cohesive and elastic ecosystem. By encapsulating Layer 2 traffic over IP networks, it removes the physical limitations of traditional VLANs and enables modern architectures of high geographic availability. Mastering this technology is not just an exercise in network theory, but a strategic necessity for companies seeking resilience, scalability, and operational agility on a global scale.