Not quite sure why as obviously the hostapd service comes up on boot and the /etc/network/interfaces file has that exact mode setting line. But the bridge comes up with the wireless card disabled and while the mode setting line will enable it, it requires the hostapd restart to work.
Anyway, the fact I know what to do means it is easy to restore the network to full capacity, but it would be nice if it worked off-the-bat.
The wlan0 <–> eth0 ethernet bridge I have on my server now essentially works well, apart from a few issues.
The most serious seems to be that the wireless card will suddenly stop working – in the sense of disassociating and then refusing to re-associate. The first time it did this it took 10 days, the second about three: I think this is a known problem – as I read about it when I was tearing my hair out about how to set the thing up, though I cannot find a reference to it now – will keep on searching.
The other is a less serious problem – as I know how to fix it. When the machine comes up the wireless part of the bridge is disabled but can be restarted with:
So, I have taken the Belkin RT2500 card out and replaced it with a decade old DLink DWL-650 (a locked down PCMCIA <–> PCI bridge) – this has a Prism chipset and so should work. But right now I cannot even get the wireless card to come up, never mind bridge it…
adrian@dragoneye:~$ sudo hostapd -ddd /etc/hostapd/hostapd.conf
[sudo] password for adrian:
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan1.
nl80211 driver initialization failed.
wlan1: Unable to setup interface.
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…