Update: This – http://cartesianproduct.wordpress.com/2012/12/22/raspberry-pi-as-an-ethernet-to-wifi-bridge/ – is a more recent article about how bridge a Debian-like system. I would start from there!
Image via Wikipedia
My triumph of the day has been to set up a bridged connection between a wireless card and a wired internet connection – substantially improving the coverage afforded by my wireless network.
Doing this proved to be rather more hard going than I thought it would be (or indeed it should have been) so I am going to write this blog in the hope that it helps someone later to not make the same mistakes – even it does reveal me as being a bit silly.
Why a bridge
A bridge transparently joins two sections (segments) of network together – in fact most consumer routers (switches) have bridge-like characteristics – allow networks to look like they are seamlessly joined together in one big segment when in fact packets are only being forwarded to bits of the network that might need them (so reducing collisions and increasing network throughput).
In my case I had a PC which had a wired network connection and an idle wireless card – and as it was in a corner of the house where wireless coverage is poor it seemed like a good idea to activate the wireless card.
Using a bridge as opposed to turning the PC into a router was the better option because it meant all the boxes could be on the same subnet and allows laptops to be moved around while maintaining the same IP address and I only needed one DHCP daemon on the network – but I didn’t fully understand that until this morning – and I went so far as to set up a DHCP daemon on the box.
When a wireless box seeks a DHCP connection it broadcasts the request – the bridge transparently passes that on through the network and so there is no need to set up a second DHCP daemon, the existing one will send the reply packets back to the bridge which will then pass them on (if required) via the wireless link.
How to do it
First of all get the wireless card working with hostap – you can download the “hostap” package from Synaptic – but you have to do some setup – configuring a hostapd.conf. This is mine (some details changed for security reasons) – and, yes, I know WEP gives very little security:
This lives in /etc/hostap/hostapd.conf and you also have to edit /etc/default/hostapd so that it knows where the config file is.
Starting the daemon (eg sudo /etc/init.d/hostapd start) sets the card in “master” mode, so it can drive an infrastructure network (ie just like your router/switch) but until you turn the bridging on, it is of no use.
To do that you can edit your /etc/network/interfaces file – adding lines like these at the end:
iface br0 inet dhcp
bridge-ports eth0 wlan0
Then rebooting your machine or typing “sudo ifup br0″ should bring the bridge up…