Wi-fi + Ethernet Bridging


2 posts
by instanttim » Sat Dec 14, 2013 7:04 am
There are many threads for people trying to get this sort of bridging and that sort of bridging. Access points, hot spots, this distro and that. I'm struggling to get my own problem to work and I find the other threads have different and conflicting information, with little explanation of the mechanics.

So unfortunately, I'll start a new thread.

Problem: I have a RPi that needs to connect to a wireless network in my home. I have another device right next to it which doesn't have wireless ability, but I can plug it into the RPi's built-in ethernet port. This is the same as many people wanting to get their TV on wi-fi...

Knowns:
  • I'm using bridge-utils. I hope this isn't misguided. Seems like others can get this to work.
  • I'm not particularly interested in dealing directly with iptables or ebtables or any of those.
  • I'm not bridging between two IP networks, they should all be using the same address range (10.0.0.x) and be on the same subnet.
  • I AM bridging between wi-fi and ethernet.
  • I get get the RPi up on wifi.

Notable: I can get this to work using dedicated hardware for bridging, notably an Airport Express. But this requires the Airport, a switch/hub, three power adapters, and 13 watts. If i can do this all with the RPi exclusively, then i am under 4 watts. For reasons that aren't important, I want/need this to be very low power.

Specific qustions/problems I've had with other threads:
  • Should the bridge interface get an IP itself? how is that even possible without a MAC?
  • Should the iface statements for the real interfaces be static? manual? dhcp? I'd ultimately like the addresses be dhcp assigned, but i've seen people claim to use manual and have the dhcp still assign them. I don't know how that works.
  • I fear my USB-WiFi doesn't support promiscuous mode. I get messages stating that I can't add the wlan0 interface to the bridge. Operation is not permitted. How can I check if this is supped to work? It's a TPLINK adapter with an Atheros chipset.

When I tried manually:
Code: Select all
brctl addif br0 wlan0
can't add wlan0 to bridge br0: Operation not supported


No better when i had it all in network/interfaces... the wlan0 just wouldn't participate.
Code: Select all
##
## loopback interface
##
auto lo
iface lo inet loopback

##
## wi-fi interface
##
auto wlan0
iface wlan0 inet manual
#  wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
  wpa-ap-scan 1
  wpa-ssid "My Lovely Network"
  wpa-psk "SuperSecretPassword"
  wpa-proto RSN
  wpa-pairwise CCMP TKIP
  wpa-group CCMP TKIP
  wpa-key-mgmt WPA-PSK

##
## ethernet interface
##
auto eth0
iface eth0 inet manual

##
## bridging interface betwen wi-fi and ethernet
##
auto br0
iface br0 inet dhcp
  bridge_ports eth0 wlan0
  bridge_stp off
  bridge_maxwait 5

  wpa-iface wlan0
  wpa-bridge br0
Posts: 4
Joined: Mon Nov 18, 2013 6:33 pm
by DougieLawson » Sat Dec 14, 2013 11:26 am
The nature of bridging interfaces is exactly the same as setting up your RPi was a wireless access point.

Here's my /etc/network/interfaces file from that experiment (eth0 was connected to the router in this case).
Code: Select all
auto lo
iface eth0 inet static
address 10.1.1.7
gateway 10.1.1.1
netmask 255.255.255.0
hostapd /etc/hostapd/hostapd.conf # you can probably ignore this line

auto br0
iface br0 inet static
address 10.1.1.8
gateway 10.1.1.1
netmask 255.255.255.0
bridge_ports eth0 wlan0


On my network, every machine that's either permanently connected or running a service gets a static address. Every other phone / laptop / tablet / kindle / Xbox / PS4 gets a DHCP address.

10.1.1.1 is my ADSL gateway/router/swich. I use the range 10.1.1.[2-29] for servers. 10.1.1.[30-100] for DHCP, 10.1.1.[230-254] for NAS, WiFi AP & Printer. I'm also running a SIT 6to4 tunnel (now using Hurricane Electric) so every machine that can do IPv6 gets an IPv6 address.

You have to bridge the machine that has two interfaces (one is connected to your router, the other is free for a secondary machine to use).

It's very easy with a Windows Laptop to bridge WiFi and Ethernet. I've used that to connect my RPi with a cable.
Hacker on ZX80 and Microtan65
Unemployed mainframe database specialist.
Linux hacker since 1995.
RPi owner since 2012.
Twitter: @DougieLawson

Gaffer tape is "The Force", it has a dark side and a light side and it holds the Universe together.
User avatar
Posts: 3742
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK