Bridging in Linux

For many reasons, mostly experimental, I wanted to set up a bridging interface in one of my Linux boxes. (The biggest reason was that I wanted to set up a transparent Squid proxy on a few of my machines on the internal network, and this seemed to be the best way if I didn't want to put the proxy on the firewall box, which I didn't.)

Setting up a bridge is pretty easy, on the command line:

ifconfig eth0 0.0.0.0 promisc up

ifconfig eth1 0.0.0.0 promisc up

brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth1
The trick is doing this in the /etc/network/interfaces file (in Debian/Ubuntu). I was pretty sure the syntax was the same as doing a physical interface, and the documentation and Google searching I did confirmed that it should look like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address 192.168.0.10
        network 192.168.0.0
        netmask 255.255.255.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge_ports eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off

But it was those last few lines, the bridge_fd through bridge_stp that I didn't understand, and I went on a quest to discover what the extra bridging parameters meant.

Maybe I missed it, but the documentation on bridging parameters in the 'interfaces' file in Debian Linux is hard to find, or at least, hard to search for. 

I came across a great reference here , though, and it told me:

bridge_fd is the bridge forward delay time, in seconds, default 15.

bridge_hello is the bridge hello time, in seconds, default 2.

bridge_maxage is the bridge's maximum message time, in seconds, default is 20.

bridge_stp controls the spanning tree protocol, on or off. Default is off, and is recommended to stay that way.

I hope this helps someone else looking to set up a Linux bridge. Thanks to this reference for getting the whole thing started, and to this reference for telling me how the bridge is configured in the interfaces file.

Comments

Eric said…
Exactly what I was wondering, too