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

Configuring Ethernet Bridging

Connect multiple network segments using Linux bridge devices.

In this lesson, you will learn how to unify multiple network segments into a single broadcast domain using Linux bridge devices.

The Bridge Concept

Think of a network bridge as a virtual "Layer 2 switch" inside your Linux kernel. Just as a physical switch connects multiple ethernet cables to allow devices to communicate at the Data Link layer, a Linux bridge connects multiple virtual or physical network interfaces so they behave as if they are plugged into the same local area network (LAN). When a frame arrives at one interface, the bridge inspects its destination MAC address and decides whether to forward it to the other interfaces or drop it.

Practical Implementation

To create a bridge, we utilize the bridge-utils package (often controlled via the ip command suite). Imagine you have two physical interfaces, eth0 and eth1, and you want to bridge them together to transparently pass traffic between two distinct physical segments.

First, you create the bridge device, then you "enslave" your physical interfaces to it:

# 1. Create the bridge interface named 'br0'
sudo ip link add name br0 type bridge

# 2. Add your physical interfaces to the bridge
sudo ip link set eth0 master br0
sudo ip link set eth1 master br0

# 3. Bring everything up
sudo ip link set eth0 up
sudo ip link set eth1 up
sudo ip link set br0 up

Once configured, br0 acts as a single logical network interface. Any machine connected to eth0 can now communicate directly with machines on the segment connected to eth1.

Key Considerations

When configuring bridges, remember that because the bridge acts as a switch, it learns MAC addresses automatically. However, you must ensure that your system's net.bridge.bridge-nf-call-iptables kernel parameters are set correctly if you intend to apply firewall rules (like ebtables or nftables) to the traffic flowing between the bridged segments. If the bridge is intended to be purely transparent at Layer 2, you generally do not assign an IP address to the physical ports, but rather to the bridge device itself if the host needs to participate in the network.

Key Takeaway: Ethernet bridging allows you to transparently merge multiple network interfaces into a single Layer 2 segment, enabling cross-segment communication as if all devices were physically connected to the same switch.