Network bridge

Introduction
A network bridge can be used to connect two independent network segments at layer 2 level (much like a router). Common applications include transparent proxying, transparent filtering (using iptables) and saving money on hardware as some mainboards come with two PHY interfaces. For this how-to, eth0 and eth1 are used but of course they can be replaced by whatever you need.

The way bridging works on Linux is that a bridging device is created (brX) that contains at least two network devices as ports (e.g. ethX or pppX). As the bridge works on layer 2, no IP addresses are needed on the port devices - on a typical setup, the bridging device itself will receive the IP (e.g. via DHCP).

Installation
Install :

Host Configuration (using OpenRC init scripts)
First, we need to add the bridge device to the file. As an example, bridge configuration with DHCP:

More documentation can be found in.

Next, create the init script and start the interface as follows:

Finally, to make sure the bridge is automatically set up on subsequent boots, run:

Host Configuration (using systemd)
First, we need to add the bridge device to the file. As an example, bridge configuration with fixed IP address (192.168.1.2 connected to the gateway 192.168.1.1 by eth0):

Next, create a systemd unit script and start the interface as follows:

Finally, to make sure the bridge is automatically set up on subsequent boots, run:

External Resources

 * Official Linux network bridge documentation
 * Generic Linux network bridge how-to
 * Article on the inofficial gentoo wiki with VLAN and iptables examples