Linux as a bridge
As you may already know you can set up a linux box to work as a bridge. Suppose you want to bridge eth0 and eth1 interfaces. The steps are these:
# yum install bridge-utils # brctl addbr br0 # brctl addif br0 eth0 # brctl addif br0 eth1 # brctl stp br0 on
These changes are not permanent. It you want to maintain them between reboots you have to edit some files:
- Create /etc/sysconfig/network-scripts/ifcfg-br0 with your favourite editor.
- Add the following lines to the file:
- Save the file.
- Open the files /etc/sysconfig/network-scripts/ifcfg-eth0 and /etc/sysconfig/network-scripts/ifcfg-eth1
- Add the following line to both files:
DEVICE=br0 TYPE=Bridge STP=on BOOTPROTO=none ONBOOT=yes IPADDR=10.0.0.2 NETMASK=255.255.255.0
BRIDGE=br0
That’s it. Pretty easy huh?
Note1: a bridge doesn’t need an IP address. However you can always assign one for management purposes.
Note2: I’m using Centos 5.3. The configuration files on other distributions may vary. For example on Ubuntu the network configuration is stored on /etc/network/interfaces.
Get Jorge Martinez de Salinas delivered by email