Bridging vs Routing in Linux Virtual Interfaces

Configuring network connectivity for virtual machines, containers, and network namespaces in Linux primarily relies on either bridging or routing. While both methods enable virtual interfaces (such as veth pairs or tap devices) to communicate with external networks and other hosts, they operate at different network abstraction layers, handle broadcast traffic differently, and demand distinct IP management strategies. Understanding these core differences ensures optimal performance, security, and scalability for virtualized Linux environments.

The Fundamental Difference: OSI Layers

The primary distinction between bridging and routing lies in the OSI layer at which each operates:

Linux Bridging: Characteristics and Behavior

In a bridged configuration, multiple virtual interfaces (such as tap interfaces for KVM/QEMU or veth endpoints for containers) are attached to a virtual bridge interface (often named br0 or docker0).

Key characteristics include:

Linux Routing: Characteristics and Behavior

In a routed configuration, the Linux host acts as a gateway or router. Each virtual interface or set of interfaces resides on a distinct IP subnet separate from the host's physical local area network.

Key characteristics include:

When to Choose Bridging vs. Routing

Feature Bridging (Layer 2) Routing (Layer 3)
OSI Layer Layer 2 (Ethernet) Layer 3 (IP)
Addressing MAC-based switching IP-based forwarding
Subnetting Shares the host network's subnet Requires dedicated/separate subnets
Broadcast Isolation None (broadcasts propagate) Full (broadcasts are contained)
External Visibility Directly accessible via LAN Requires NAT or upstream route configuration

Use Bridging when:

Use Routing when: