Wired to wireless bridge in Linux

I am attempting to set up my Raspberry Pi as a bridge, using Debian wheezy. I have a hostapd.conf: (some details changed for security, and yes, I know WEP is no good)…

interface=wlan0bridge=br0driver=nl80211auth_algs=1macaddr_acl=0ignore_broadcast_ssid=0logger_syslog=-1logger_syslog_level=0hw_mode=gssid=MY_SSIDchannel=11wep_default_key=0wep_key0=MY_KEYwpa=0

And this in /etc/network/interfaces:

auto loiface lo inet loopbackiface eth0 inet dhcpallow-hotplug wlan0iface wlan0 inet manualwpa-roam /etc/wpa_supplicant/wpa_supplicant.confiface default inet dhcpauto br0iface br0 inet dhcpbridge-ports eth0 wlan0

Everything seems to come up ok, but I cannot associate with the bridged wireless connection – even though the flashing lights on the USB stick suggest packets are being exchanged.

I have read somewhere that not all cards/devices will run in hostap mode – they won’t pass packets in one direction: is that right? (The info was a bit old)- this my card:

[    3.663245] usb 1-1.3.1: new high-speed USB device number 5 using dwc_otg[    3.794187] usb 1-1.3.1: New USB device found, idVendor=0cf3, idProduct=9271[    3.804321] usb 1-1.3.1: New USB device strings: Mfr=16, Product=32, SerialNumber=48[    3.816994] usb 1-1.3.1: Product: USB2.0 WLAN[    3.823790] usb 1-1.3.1: Manufacturer: ATHEROS[    3.830645] usb 1-1.3.1: SerialNumber: 12345

So, what have I got wrong here?

Update: So I have done further investigations and can get the bridge up, but seemingly that destroys the (wired) ethernet connection, which is odd. E.g., on the RPi:

Boot the system…

ping 192.168.62.1 

(router) – this works

Attempt to associate with wireless LAN … fails (or rather “with limited connectivity” on Android phone – no good)

brctl showmacs br0

This just shows mac of wlan0 and mac of phone at this point

brctl addif br0 eth0 wlan0

At this point I can now associate the phone with the wireless network, but…

ping 192.168.62.1

…fails

And similarly I can no longer ping the RasPi from any other machine on the network

Running

ifconfig br0

Suggests the bridge is dropping packets…

Any ideas?

Further update: The /etc/network/interfaces file now (and for the above sequence) reads:

auto lo eth0iface lo inet loopbackiface eth0 inet dhcpallow-hotplug wlan0#wpa-roam /etc/wpa_supplicant/wpa_supplicant.confiface default inet dhcp

Solution:

Bridges made easy:

There is a project on sourceforge made just for your situation. http://sourceforge.net/projects/bridger/ It even comes as a deb package.

With regard to ‘dropping’ packets:

  1. Did you check to see if iptables is set to default drop?  sudo iptables --list  should say “ACCEPT, ACCEPT, ACCEPT” for a box of this type.  If that’s the issue turn it off.

  2. Are you even forwarding the packets, bro? Make sure the line “net.ipv4.ip_forward=1” is NOT commented in /etc/sysctl.conf (it is by default), then restart your networking.

  3. Promiscuous mode is not supported by your wireless dongle.  (meaning it can’t accept packets that are not destined for it)

Pure Bridge vs. Shared Bridge:

  1. iface br0 inet dhcp indicates a shared bridge, meaning that the bridge itself gets an ip and can be an endpoint for traffic.

  2. A pure bridge does not get an ip address and only forwards traffic between the two interfaces

  3. Shared Bridge Sample /etc/network/interfaces config file (Debian/Ubuntu)

# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).# The loopback network interfaceauto loiface lo inet loopback# Bridge between eth0 and wlan0auto br0iface br0 inet dhcp  pre-up ip link set eth0 down  pre-up ip link set wlan0 down  pre-up brctl addbr br0  pre-up brctl addif br0 eth0 wlan0  pre-up ip addr flush dev eth0  pre-up ip addr flush dev wlan0  post-down ip link set eth0 down  post-down ip link set wlan0 down  post-down ip link set br0 down  post-down brctl delif br0 eth0 wlan0  post-down brctl delbr br0

Restart the network: sudo /etc/init.d/networking restart After making complex network configuration changes its easier to just reboot rather than make sure everything restarted properly in the reboot.

You think you have routing issues:

  1. Eliminate DNS as a cause by testing with ping 8.8.8.8.  If this works, then you probably have a DNS issue in your network.

  2. Check your gateway with sudo ip route hopefully you see default via 192.168.1.1 dev br0 proto dhcp (assuming your gateway is 192.168.1.1).  If it’s missing or wrong, fix it sudo ip route add default via 192.168.1.1.  Test again: ping 8.8.8.8

  3. Renew your shared bridge ip with dhclient br0 and retest with ping 8.8.8.8

  4. Check your ‘slave’ interfaces with ifconfig and make sure eth0 and wlan0 do NOT have ip addresses.  They are a part of the bridge now.  If they do, make sure you remove them from all the config files, set them to static 0.0.0.0 or something.

If NONE of this works, try that debian bridging app, and if that doesn’t work then your wireless dongle doesn’t support promiscuous mode.  (see above)

If it works at any time here, reboot and make sure it still works.