Creating a layer 2 ethernet bridge under Debian (or Linux in general really) is incredibly easy, as are most things. What a L2 bridge actually is, is outside the scope of this guide, however Google has plenty of information. Essentially, ethernet frames are mirrored between the two interfaces, therefore what Layer 3 protocol data (TCP, UDP, ICMP, etc) is within the ethernet frame is irrelevant. Anyway, back to the point..
In case you don’t have the package, apt-get install bridge-utils and you’ll also need bridge support in your kernel, however unless you specifically removed it, you should have it.
Assuming that you want to create a bridge between interfaces eth0 and eth1
ifconfig eth0 0.0.0.0 #remove IP from eth0
ifconfig eth0 up #ensure the interface is up
ifconfig eth1 0.0.0.0 #remove IP from eth1
ifconfig eth1 up #ensure the interface is up
brctl addbr br0 #create br0 node
brctl addif br0 eth0 #add eth0 to bridge br0
brctl addif br0 eth1 #add eth1 to bridge br0
ifconfig br0 192.168.1.100 netmask 255.255.255.0 #or relevant settings for your network
ifconfig br0 up #bring up interface
route add default gw 192.168.1.1 #or relevant settings for your network
Job done!
To remove the bridge:
brctl delif br0 eth1 #remove eth1 from bridge
brctl delif br0 eth0 #remove eth0 from bridge
brctl delbr br0 #remove bridge br0
Creating a bridge between different types of device will potentially not work. i.e. if you attempt to bridge a wireless adapter with a regular ethernet adapter, you will likely encounter problems. This could be because of differing frame sizes, or most likely, because your wireless firmware does not support the spoofing of MAC addresses which is required to make the bridge work. This is not a bug in the bridging software, but a limitation of most wireless adapter firmwares.
Also note that your br0 interface does not require an IP address, as far as Layer 3 and IP related protocols are concerned, this bridge doesn’t even exist.
Tags: brctl, bridge, bridge-utils
You must be logged in to post a comment.
Dear Adam,
I am trying to do linux arbitrator, but there are commands in that like “brctl getmacip” , “brctl getbuff”. The problem is I dont see any getcommands in brctl options. Am I missing something ? Please help.