Friday, May 9, 2008

How to setup network bridge

I have written following tutorial based on my system(Debian). It may work with little or no modification in your system too.

First of all what is a network bridge?
According to www.linux-foundation.org
A bridge is a way to connect two Ethernet segments together in a protocol independent way.
I assume if you are reading this then you must know lot more than this.

So how do we create a bridge then? In windows it is very simple, just select the interfaces, right-click them and select create bridge.

In Linux, you need to do it following:

Edit your /etc/network/interfaces file
vi /etc/network/interfaces

Add the following codes
iface br0 inet static
address 172.16.5.1
netmask 255.255.255.224
gateway 172.16.5.5
bridge_ports eth0 eth1


OR

iface br0 inet dhcp
bridge_ports eth0 eth1


Save and exit.
Go to Terminal.
sudo ifup br0

Doing so will produce the following error

SIOCSIFADDR: No such device
br0: ERROR while getting interface flags: No such device
br0: ERROR while getting interface flags: No such device
wifi0: unknown hardware address type 801
Bind socket to interface: No such device
Failed to bring up br0.


This is because you haven't installed the package bridge-utils
In terminal type sudo apt-get install bridge-utils

Bingo! you are done.

If you want the bridge to be up automatically then you can add auto br0 in the /etc/network/interfaces file somewhere near the above added lines.

No comments:

Post a Comment