Reply To: My Router Runs Linux
OK. I got the bridge working and learned way more than I ever wanted to about wifi.
The wifi specs define up to 4 mac address fields to identify the wireless transmitter, wireless receiver, plus the sender and destination. For the common case involving an access point and multiple clients, only 3 of the four fields are needed since the wireless receiver and destination are the same. To get bridging to work requires a wifi card which supports 4-address mode. My new Atheros-based card just happened to support it. Here’s the procedure I used.
First, I had to “recreate” the device because it was the only example I could find of setting “4addr on”. Using “iw” is new to me so I’m hoping I’ll figure out the syntax that lets me set 4addr on an existing device.
iw phy phy0 interface del wlan0 iw phy phy0 interface add wlan0 type managed 4addr on
Then I invoked wpa_supplicant with the “-b br0 option” to support bridging.
wpa_supplicant -D wext -b br0 -c /etc/wpa_supplicant.conf -i wlan0
Now I’m associated to the access point but neither wlan0 or eth0 should have an IP address at this point.
Next I added wlan0 to my existing bridge.
brctl addif br0 wlan0
Now adding eth0,
brctl addif br0 eth0
Even though most docs say the br0 will have the mac address of the first device added, for some reason it switches when adding eth0 so I have to manually change it back,
ifconfig br0 hw ether <mac of wlan0>
Now I configure my IP address on br0. At this point I can ping the router and google but I’m not quite done. There’s still a limitation of my Netgear access point. As described here, it will not accept traffic with a mac address other than that of the associated wifi card. I used the ebtables solution described on that page and suddenly my wired desktop can connect through the bridge on the server.
It’s probably not a true bridge because ebtables is performing some kind of layer 2 NATing but I’m able to connect from a wireless computer to my wired desktop without needing to setup port forwarding so I think it’s a little better than a layer 3 NAT setup.
Even though I tested it, I’m still not sure if everything is correct. I continue to receive kernel messages such as “wlan0: received packet with own address as source address”. I have a feeling upgrading the kernal might suppress these.
Now I just need to work on getting this automated with “ifup”. If I discover something seriously wrong such as this causing my wifi card to overheat and catch on fire, I’ll let you know.