|
/Linux/router-bridge:
Easy Connection Sharing with a Network Bridge
Suppose you have two computers and only one network cable coming into the room, and you want to save a few bucks and a bit of clutter and not buy a switch....
One could set up one of the computers as a router per [1], creating a sub-network within the room. But what if you do *not* want to create a sub-network, ie. you want both computers on the same network?
The solution is to create a transparent network bridge between two ethernet interfaces on one of the computers. On Debian, I use the bridge-utils[2][3] package.
The bridge-utils-interfaces[4] manpage is a bit general, the best reference I have found is here[5].
Setup is really quite simple in principle. Create the following stanza in /etc/network/interfaces:
auto br0 iface br0 inet dhcp bridge_ports eth0 auto eth2 iface eth2 inet manual up ifconfig $IFACE 0.0.0.0 up post-up brctl addif br0 eth2
Here eth0 is attached to the outside network, and added to the bridge br0 immediately. The br0 dhcp gets its IP through eth0, and the local computer networks through br0-eth0. (This should work irrespective of whatever might be going on with eth2.) eth2 is added to the bridge, but it is not configured locally with an IP because it does not need an IP. The only part eth2 plays in the network is to relay traffic between the br0 bridge and any computer attached to it. Any computer connecting to eth2 must take care of its own IP, through DHCP, for example, which the bridge would just relay to the DHCP server in the outside network.
At this point I have my firehol firewall turned *off*, which is non-ideal. Once I figure out how to incorporate a firewall into bridging, I will post.
[1]http://blog.langex.net/index.cgi/Linux/router-bridge/build-your-own-router.html
[2] http://linuxfoundation.org/en/Net:Bridge
[3] http://manpages.debian.net/cgi-bin/man.cgi?query=brctl&apropos=0&sektion=0&manpath=Debian+Sid&format=html&locale=en
[4] http://manpages.debian.net/cgi-bin/man.cgi?query=bridge-utils-interfaces&apropos=0&sektion=0&manpath=Debian+Sid&format=html&locale=en
[5] http://wiki.openzaurus.org/HowTos/Bridging_with_Ubuntu
posted at: 08:04 | path: /Linux/router-bridge | permanent link to this entry