How to make a layer 2 bridge between two or more Ethernet interfaces on Ubuntu Linux


The layer 2 bridging is an implementation of IEEE 802.1 D. This is the transparent bridging that was used in Ethernet layer bridges.

Install package:

apt-get install bridge-utils

Next we’ll create a fake bridge interface:

brctl addbr br0
brctl stp br0 on # Enable STP in case of network loops

Now we can add interfaces to the bridge:

ifconfig eth0 down 
ifconfig eth1 down
brctl addif br0 eth0
brctl addif br0 eth1
ifconfig eth0 up
ifconfig eth1 up
ifconfig br0 up

Add ip for the interface if we wanna be able to connect to the host:

ifconfig br0