trbennett48
Posts: 8
Joined: Mon Feb 10, 2014 8:46 pm

How to setup RPI to bridge ethernet & Wifi

Sun Feb 08, 2015 5:06 am

My RPI currently uses WIFI to connect to the internet via a Wireless Router.
I would like to use my RPI to act as a bridge for some other devices that only have Ethernet
networking capability.

I've read some other RPI Bridge postings, but it appears most work the other way around,
i.e. use the RPI as a "Wireless Access Point", and bridge other devices to the
the RPI's ethernet connection to a router.... This is not what I want to do.

Any guidance would be greatly appreciated.

jolouis
Posts: 15
Joined: Wed Sep 10, 2014 8:50 pm

Re: How to setup RPI to bridge ethernet & Wifi

Mon Feb 09, 2015 3:20 pm

The configuration is the same in regards to the bridging... the only difference is what you use to setup your Wifi device. Once the wifi is up (your Wlan0 interface has an IP address and is live on the network), the bridge configuration will work (you basically create a bridge, add wlan0 and eth0 to it, and boom you're good to go). The only hiccup you might run into is what happens if the wifi device goes down, but as long as the interface doesn't get clobbered it shouldn't matter... on the other hand, if you've done your homework you should already have a udev rule in place to handle the up/down behaviour and adjust the bridge accordingly...

trbennett48
Posts: 8
Joined: Mon Feb 10, 2014 8:46 pm

Re: How to setup RPI to bridge ethernet & Wifi

Wed Feb 11, 2015 6:33 am

Still having no joy...
Based upon various posts, I have modified the /etc/network/interfaces to contain the following:

Code: Select all

auto lo

iface lo inet loopback

iface eth0 inet manual

auto wlan0
iface wlan0 inet manual

auto br0
iface br0 inet dhcp
        bridge_ports wlan0 eth0
        bridge_stp off
        bridge_fd 0
        bridge_waitport 0

wpa-iface wlan0
wpa-bridge br0
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Then a reboot...
When reboot has completed, I run

Code: Select all

ifconfig -a

and it shows the following:

Code: Select all

br0       Link encap:Ethernet  HWaddr b8:27:eb:7a:15:8d
          inet6 addr: fe80::ba27:ebff:fe7a:158d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:32 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:18432 (18.0 KiB)  TX bytes:3042 (2.9 KiB)

eth0      Link encap:Ethernet  HWaddr b8:27:eb:7a:15:8d
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:32 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:18432 (18.0 KiB)  TX bytes:3162 (3.0 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:0f:55:a6:0c:fd
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:329 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:87340 (85.2 KiB)  TX bytes:288 (288.0 B)
Note, before I started the bridging work, wlan0 was correctly configured to
talk to my wifi-access-point-router...

You will note that wlan0 and eth0 do not have an IP address associated with them...
... and br0 has only an IPv6 address associated with it. My expectation is for an
IPv4 address.

For now, I have reset /etc/network/interfaces back to the original (i.e. working) contents.

Any ideas...???

Thanks,
-tony

trbennett48
Posts: 8
Joined: Mon Feb 10, 2014 8:46 pm

Re: How to setup RPI to bridge ethernet & Wifi

Wed Feb 11, 2015 8:40 am

This Debian Bridge setup link
https://wiki.debian.org/BridgeNetworkCo ... reless_NIC
seems to indicate that for a Wireless NIC it is necessary to install and run "ebtables" ...
... and configure rules for each ethernet device being bridged.

Do I understand this correctly???

jolouis
Posts: 15
Joined: Wed Sep 10, 2014 8:50 pm

Re: How to setup RPI to bridge ethernet & Wifi

Wed Feb 11, 2015 4:01 pm

Hmm interesting, as I said I've never tried to do it that way before but they key point from the debian page was:
most Access Points (APs) will reject frames that have a source address that didn’t authenticate with the AP. Since Linux does ethernet bridging transparently (doesn’t modify outgoing or incoming frames), we have to set up some rules to do this with a program called ebtables.
If you look at your ifconfig, you'll notice that the bridge has taken on the MAC address of your eth0 rather than that of your wlan0. That's probably why the AP doesn't want to talk to it and hand out an IP address (I'm not sure what that IPv6 address is but maybe it's a default or something?). Try setting up ebtables as described in that document and see if it makes any difference. Unfortunately my USB->wifi adapter is busy in another setup at the moment so I can't test myself.

trbennett48
Posts: 8
Joined: Mon Feb 10, 2014 8:46 pm

Re: How to setup RPI to bridge ethernet & Wifi

Wed Feb 11, 2015 8:55 pm

The problem I have with ebtables is that you have to set up a rule for EVERY
ethernet device that uses the PI's ethernet to access the ethernet.

That is disconcerting to me, because I was going to use the PI to replace a WET640N
Linksys WIFI bridge that I've used for 9 years... It worked without needing to specify
any rules... My hope was for the PI to be able to do the same...

baantonia
Posts: 63
Joined: Fri Feb 06, 2015 2:19 pm

Re: How to setup RPI to bridge ethernet & Wifi

Tue Mar 10, 2015 7:00 pm

I've set up a number of Raspberry Pi's to enable some, hard to cable, Trend boiler monitor devices access to the network.

The RPi's wifi was set to obtain its IP address via DHCP which was set in a reservation using the wifi dongle's MAC address. The IP address of eth0 was set to be a static address with the Trend boiler unit being on the same range and its gateway address being that of the eth0 interface of the RPi. DNS setting on the boiler monitor was set to that used on the rest of the network. With some tinkering of iptables to forward certain ports to the boiler monitor and setting up NATting, the rest of the network sees the boiler monitor as the RPi's wifi IP address but knows nothing of the address range between the RPi and the boiler monitor. Ports such as ssh (22) were left unforwarded so the RPi's could be accessed for configuration. All this required no bridging interface.

eggy
Posts: 3
Joined: Fri Feb 27, 2015 10:52 pm

Re: How to setup RPI to bridge ethernet & Wifi

Tue Mar 10, 2015 11:44 pm

If you look at your ifconfig, you'll notice that the bridge has taken on the MAC address of your eth0 rather than that of your wlan0.
I'm doing a similar setup: <Laptop> to <eth0> bridge <wlan0> to wifi-ap-Network.
I changed my /etc/network/interfaces file to same as the earlier post (verbatim) and rebooted.
my 'br0' took on the MAC of my wlan0, however, my (wired) laptop still won't dhcp.
my 'pi' did connect to the wifi/internet (on it now in fact).
I'll bet the AP won't issue another 'ip' (for the laptop requests), cause it already gave one to the wlan0 MAC. - maybe give laptop the same 'static' ip as the 'br0'?

i'll let you know if/when i get the laptop working. noob here.

Code: Select all

br0       Link encap:Ethernet  HWaddr 00:13:ef:30:14:05  
          inet addr:172.22.131.180  Bcast:172.22.135.255  Mask:255.255.248.0
          inet6 addr: fe80::f4e6:31ff:fec7:91ed/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:733 errors:0 dropped:0 overruns:0 frame:0
          TX packets:240 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:209797 (204.8 KiB)  TX bytes:27217 (26.5 KiB)

eth0      Link encap:Ethernet  HWaddr b8:27:eb:75:31:c9  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:56 errors:0 dropped:0 overruns:0 frame:0
          TX packets:464 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7896 (7.7 KiB)  TX bytes:56905 (55.5 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:13:ef:30:14:05  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:682 errors:0 dropped:2 overruns:0 frame:0
          TX packets:291 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:225806 (220.5 KiB)  TX bytes:40789 (39.8 KiB)


RichardV
Posts: 1
Joined: Wed Mar 11, 2015 10:32 am

Re: How to setup RPI to bridge ethernet & Wifi

Wed Mar 11, 2015 10:38 am

Hi All,

May I recommend the excellent step-by-step tutorial by Robin Newman at https://rbnrpi.wordpress.com/project-li ... -ready-tv/

Although it talks about wireless to ethernet bridging from the point of view of connecting a smart TV to wireless using a Raspberry PI, clearly it works when bridging any ethernet device to wireless, including a switch.

I've used it myself for this purpose several times.

Richard

eggy
Posts: 3
Joined: Fri Feb 27, 2015 10:52 pm

Re: How to setup RPI to bridge ethernet & Wifi

Mon Mar 16, 2015 1:56 am

I finally got mine to work by following the post
by gabeblack » Fri Dec 28, 2012 10:13 pm
from the thread:
http://www.raspberrypi.org/forums/viewt ... 58#p719758

This worked on my home network, but not on the wireless network where i work.
The AP at my work must have safegaurds in place to prevent it working.

Return to “Networking and servers”