SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Fri Dec 29, 2017 1:34 am

Did you use a bridge access point setup?
What IP does your laptop have?
What IP does your ethernet device have?

lewmur
Posts: 368
Joined: Sun Dec 25, 2011 3:20 pm
Contact: Website

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Fri Dec 29, 2017 11:25 pm

I'm running the latest Raspian version -stretch- and when I add the eth0 entry in /etc/network/interfaces and reboot, the wlan0 no longer connects and when I mouse over the netmanager icon it says it has lost connection to dhcpcd.

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 1:13 am

lewmur wrote:
Fri Dec 29, 2017 11:25 pm
I'm running the latest Raspian version -stretch- and when I add the eth0 entry in /etc/network/interfaces and reboot, the wlan0 no longer connects and when I mouse over the netmanager icon it says it has lost connection to dhcpcd.
Why are you adding an eth0 entry in /etc/network/interfaces? Only the bridge entry (br0) goes there.
https://github.com/SurferTim/documentat ... connection

lewmur
Posts: 368
Joined: Sun Dec 25, 2011 3:20 pm
Contact: Website

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 1:35 am

SurferTim wrote:
Sat Dec 30, 2017 1:13 am
lewmur wrote:
Fri Dec 29, 2017 11:25 pm
I'm running the latest Raspian version -stretch- and when I add the eth0 entry in /etc/network/interfaces and reboot, the wlan0 no longer connects and when I mouse over the netmanager icon it says it has lost connection to dhcpcd.
Why are you adding an eth0 entry in /etc/network/interfaces? Only the bridge entry (br0) goes there.
https://github.com/SurferTim/documentat ... connection
I followed the direction in the OP.
Ethernet Static IP
Next, setup a static ip for the dhcp server.
CODE: SELECT ALL

sudo nano /etc/network/interfaces
Comment out the existing eth0 line and add:
CODE: SELECT ALL

#iface eth0 inet manual
allow-hotplug eth0
iface eth0 inet static
address 172.24.1.1
netmask 255.255.255.0
network 172.24.1.0
broadcast 172.24.1.255
The directions you link are the opposite of what I want. I want to connect the Pi's wifi to an existing wifi network, bridge that to eth0 and connect to the wired connection on a laptop or the wlan port on a router.

arajasek
Posts: 41
Joined: Fri Oct 06, 2017 2:17 pm

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 2:44 am

SurferTim wrote:
Fri Dec 29, 2017 1:34 am
Did you use a bridge access point setup?
What IP does your laptop have?
What IP does your ethernet device have?
I'm not sure what your first question means. I followed OPs instructions completely. Please elaborate on that.

Ethernet Device IP: 172.24.1.132
Laptop IP: 192.168.1.112

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 10:25 am

There are two types of access point setup
1) NAT
2) Bridge

The one described in the OP is a NAT ap, and it won't work with Stretch as the OP described. This does. Use the first example.
https://github.com/SurferTim/documentat ... s-point.md

Edit: Before you decide which type ap you want, you should know this. If you use a NAT ap, the devices on the ethernet side of the RPi will not be able to connect with the wifi devices. If you want to do that, use a bridged ap (the second example).

lewmur
Posts: 368
Joined: Sun Dec 25, 2011 3:20 pm
Contact: Website

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 2:37 pm

SurferTim wrote:
Sat Dec 30, 2017 10:25 am
There are two types of access point setup
1) NAT
2) Bridge

The one described in the OP is a NAT ap, and it won't work with Stretch as the OP described. This does. Use the first example.
https://github.com/SurferTim/documentat ... s-point.md

Edit: Before you decide which type ap you want, you should know this. If you use a NAT ap, the devices on the ethernet side of the RPi will not be able to connect with the wifi devices. If you want to do that, use a bridged ap (the second example).
Actually, I'm going to be using this in a public wifi situation and would prefer that those on the etho side NOT be able to access anything on the wifi side other than the internet. Will the first example accomplish that?

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 2:46 pm

lewmur wrote:
Sat Dec 30, 2017 2:37 pm
SurferTim wrote:
Sat Dec 30, 2017 10:25 am
There are two types of access point setup
1) NAT
2) Bridge

The one described in the OP is a NAT ap, and it won't work with Stretch as the OP described. This does. Use the first example.
https://github.com/SurferTim/documentat ... s-point.md

Edit: Before you decide which type ap you want, you should know this. If you use a NAT ap, the devices on the ethernet side of the RPi will not be able to connect with the wifi devices. If you want to do that, use a bridged ap (the second example).
Actually, I'm going to be using this in a public wifi situation and would prefer that those on the etho side NOT be able to access anything on the wifi side other than the internet. Will the first example accomplish that?
Yes, and that is what you should use. Otherwise, your wifi clients would be exposed to the internet.

lewmur
Posts: 368
Joined: Sun Dec 25, 2011 3:20 pm
Contact: Website

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 4:13 pm

SurferTim wrote:
Sat Dec 30, 2017 2:46 pm
lewmur wrote:
Sat Dec 30, 2017 2:37 pm
SurferTim wrote:
Sat Dec 30, 2017 10:25 am
There are two types of access point setup
1) NAT
2) Bridge

The one described in the OP is a NAT ap, and it won't work with Stretch as the OP described. This does. Use the first example.
https://github.com/SurferTim/documentat ... s-point.md

Edit: Before you decide which type ap you want, you should know this. If you use a NAT ap, the devices on the ethernet side of the RPi will not be able to connect with the wifi devices. If you want to do that, use a bridged ap (the second example).
Actually, I'm going to be using this in a public wifi situation and would prefer that those on the etho side NOT be able to access anything on the wifi side other than the internet. Will the first example accomplish that?
Yes, and that is what you should use. Otherwise, your wifi clients would be exposed to the internet.
No, it isn't. Actually, BOTH of these methods are wrong for what I want. As I stated, I want the Pi's wifi to connect to the existing wifi network and then to share its connection with eth0. Both of your examples have the Pi's eth0 connecting to the existing network and the Pi's wifi acting as an access point.

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 4:30 pm

You were not very clear. I presumed what you wanted, since you hijacked this thread.

Set up wlan0 as a wifi client. Insure it works.

Install dnsmasq for dhcp service.

Code: Select all

sudo apt-get install dnsmasq
My /etc/dhcpcd.conf addition:

Code: Select all

interface eth0
static ip_address=192.168.6.1/24
My /etc/dnsmasq.conf file:

Code: Select all

interface=eth0
dhcp-range=192.168.6.8,192.168.6.250,255.255.255.0,12h
Edit /etc/sysctl.conf and uncomment this:

Code: Select all

net.ipv4.ip_forward=1
My iptables rule.

Code: Select all

sudo iptables -t nat -A  POSTROUTING -o wlan0 -j MASQUERADE
Then make the iptables rule permanent.

Code: Select all

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Then in /etc/rc.local, add this:

Code: Select all

iptables-restore < /etc/iptables.ipv4.nat

lewmur
Posts: 368
Joined: Sun Dec 25, 2011 3:20 pm
Contact: Website

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 5:44 pm

SurferTim wrote:
Sat Dec 30, 2017 4:30 pm
You were not very clear. I presumed what you wanted, since you hijacked this thread.

Set up wlan0 as a wifi client. Insure it works.

Install dnsmasq for dhcp service.

Code: Select all

sudo apt-get install dnsmasq
My /etc/dhcpcd.conf addition:

Code: Select all

interface eth0
static ip_address=192.168.6.1/24
My /etc/dnsmasq.conf file:

Code: Select all

interface=eth0
dhcp-range=192.168.6.8,192.168.6.250,255.255.255.0,12h
Edit /etc/sysctl.conf and uncomment this:

Code: Select all

net.ipv4.ip_forward=1
My iptables rule.

Code: Select all

sudo iptables -t nat -A  POSTROUTING -o wlan0 -j MASQUERADE
Then make the iptables rule permanent.

Code: Select all

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Then in /etc/rc.local, add this:

Code: Select all

iptables-restore < /etc/iptables.ipv4.nat
First of all, thank you for this explanation. I does what I want. But I don't think your criticism was justified. The title of the thread is "Wifi to Ethernet Bridge" which is what I was try to do, so I didn't "hijack the tread." And, in an earlier post I stated very clearly what I was trying to do.
Post by lewmur » 29 Dec 2017 20:35

SurferTim wrote: ↑29 Dec 2017 20:13
lewmur wrote: ↑29 Dec 2017 18:25
I'm running the latest Raspian version -stretch- and when I add the eth0 entry in /etc/network/interfaces and reboot, the wlan0 no longer connects and when I mouse over the netmanager icon it says it has lost connection to dhcpcd.
Why are you adding an eth0 entry in /etc/network/interfaces? Only the bridge entry (br0) goes there.
https://github.com/SurferTim/documentat ... connection
I followed the direction in the OP.
Ethernet Static IP
Next, setup a static ip for the dhcp server.
CODE: SELECT ALL

sudo nano /etc/network/interfaces
Comment out the existing eth0 line and add:
CODE: SELECT ALL

#iface eth0 inet manual
allow-hotplug eth0
iface eth0 inet static
address 172.24.1.1
netmask 255.255.255.0
network 172.24.1.0
broadcast 172.24.1.255
The directions you link are the opposite of what I want. I want to connect the Pi's wifi to an existing wifi network, bridge that to eth0 and connect to the wired connection on a laptop or the wlan port on a router.

arajasek
Posts: 41
Joined: Fri Oct 06, 2017 2:17 pm

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 6:51 pm

SurferTim wrote:
Sat Dec 30, 2017 10:25 am
There are two types of access point setup
1) NAT
2) Bridge

The one described in the OP is a NAT ap, and it won't work with Stretch as the OP described. This does. Use the first example.
https://github.com/SurferTim/documentat ... s-point.md

Edit: Before you decide which type ap you want, you should know this. If you use a NAT ap, the devices on the ethernet side of the RPi will not be able to connect with the wifi devices. If you want to do that, use a bridged ap (the second example).
Thanks a lot for your help as there are multiple threads going on here. I am interested in the bridge not NAT as I want the devices on the ethernet side to connect to devices on the Wifi side. So which second example are you referring to?

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 7:48 pm

arajasek wrote:
Sat Dec 30, 2017 6:51 pm
Thanks a lot for your help as there are multiple threads going on here. I am interested in the bridge not NAT as I want the devices on the ethernet side to connect to devices on the Wifi side. So which second example are you referring to?
In your setup is the Wi-Fi acting as a client to an existing Wi-Fi network, or is it creating a new Wi-Fi network for other devices to connect to.

In the former (which is what this thread was originally about) you'll have problems as it's not supported by the Wi-Fi standards.

n67
Posts: 938
Joined: Mon Oct 30, 2017 4:55 pm

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sat Dec 30, 2017 8:12 pm

Thanks a lot for your help as there are multiple threads going on here. I am interested in the bridge not NAT as I want the devices on the ethernet side to connect to devices on the Wifi side. So which second example are you referring to?
As I understand it, if you want to setup a bridge - where the "source" (aka, "the uplink") is eth0 and the target (aka, "the downstream") is wlan0, then all you need to do is follow the instructions at:

https://github.com/SurferTim/documentat ... et-sharing

That is, starting with:
Using the Raspberry Pi as an access point to share an internet connection
and ending with:
The ifconfig command will show the bridge, which will have been allocated an IP address via the wired Ethernet's DHCP server. The wlan0 and eth0 no longer have IP addresses, as they are now controlled by the bridge. It is possible to use a static IP address for the bridge if required, but generally, if the Raspberry Pi access point is connected to a ADSL router, the DHCP address will be fine.
That should be it - except there is a sub-reference to how to do the hostapd setup - but once you have that running, it should all be self-contained in the above section. At least that is my hope...
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sun Dec 31, 2017 2:06 am

lewmur wrote:
Sat Dec 30, 2017 5:44 pm
The directions you link are the opposite of what I want. I want to connect the Pi's wifi to an existing wifi network, bridge that to eth0 and connect to the wired connection on a laptop or the wlan port on a router.
What I posted above and you quoted does exactly that. The wlan0 interface is a client that connects to a wireless access point. The eth0 interface is assigned 192.168.6.1/24, and has a dhcp server on it for the ethernet clients (your laptop).

All traffic going out wlan0 is masqueraded.

You cannot bridge a client wlan0 interface to the eth0 interface. If you try, you will get an "operation not permitted" error.

jacobrast
Posts: 1
Joined: Sun Dec 31, 2017 8:28 am

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sun Dec 31, 2017 8:30 am

SurferTim,

Thanks for all the help. Just wanted to say that your github and posts here have been a real help to me

lewmur
Posts: 368
Joined: Sun Dec 25, 2011 3:20 pm
Contact: Website

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sun Dec 31, 2017 1:12 pm

SurferTim wrote:
Sun Dec 31, 2017 2:06 am
lewmur wrote:
Sat Dec 30, 2017 5:44 pm
The directions you link are the opposite of what I want. I want to connect the Pi's wifi to an existing wifi network, bridge that to eth0 and connect to the wired connection on a laptop or the wlan port on a router.
What I posted above and you quoted does exactly that. The wlan0 interface is a client that connects to a wireless access point. The eth0 interface is assigned 192.168.6.1/24, and has a dhcp server on it for the ethernet clients (your laptop).

All traffic going out wlan0 is masqueraded.

You cannot bridge a client wlan0 interface to the eth0 interface. If you try, you will get an "operation not permitted" error.
Read my last post again. The very first thing I said was " thank you for this explanation. I does what I want." In fact, I installed it in the Pub yesterday and it improved the signal from -80db to -65db.

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Sun Dec 31, 2017 1:16 pm

OK, good to hear. I did want to add the part about not being able to add a client wlan interface to a bridge. That caused me great grief.

razor
Posts: 13
Joined: Wed Sep 02, 2015 9:17 pm

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Thu Mar 01, 2018 2:28 pm

hard to find definitive answers in this thread... :)

Why do i need to use dnsmasq?
I want to use Raspi as a bridge (i guess that's a proper name), to connect device that doesn't have wifi to my local wifi network (wifi router). i want this device to acquire IP from wifi router dhcp.

Any more explanation what every lines do? in this thread you can find a lot of 'copy-paste' code, but without proper explanation, you can't learn anything :/
SurferTim wrote:
Sat Dec 30, 2017 4:30 pm
Set up wlan0 as a wifi client. Insure it works.

Install dnsmasq for dhcp service.

Code: Select all

sudo apt-get install dnsmasq
My /etc/dhcpcd.conf addition:

Code: Select all

interface eth0
static ip_address=192.168.6.1/24
My /etc/dnsmasq.conf file:

Code: Select all

interface=eth0
dhcp-range=192.168.6.8,192.168.6.250,255.255.255.0,12h
Edit /etc/sysctl.conf and uncomment this:

Code: Select all

net.ipv4.ip_forward=1
My iptables rule.

Code: Select all

sudo iptables -t nat -A  POSTROUTING -o wlan0 -j MASQUERADE
Then make the iptables rule permanent.

Code: Select all

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Then in /etc/rc.local, add this:

Code: Select all

iptables-restore < /etc/iptables.ipv4.nat

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Thu Mar 01, 2018 2:35 pm

razor wrote: hard to find definitive answers in this thread... :)

Why do i need to use dnsmasq?
I want to use Raspi as a bridge (i guess that's a proper name), to connect device that doesn't have wifi to my local wifi network (wifi router). i want this device to acquire IP from wifi router dhcp.

Any more explanation what every lines do? in this thread you can find a lot of 'copy-paste' code, but without proper explanation, you can't learn anything :/
SurferTim wrote:
Sat Dec 30, 2017 4:30 pm
Set up wlan0 as a wifi client. Insure it works.

Install dnsmasq for dhcp service.

Code: Select all

sudo apt-get install dnsmasq
My /etc/dhcpcd.conf addition:

Code: Select all

interface eth0
static ip_address=192.168.6.1/24
My /etc/dnsmasq.conf file:

Code: Select all

interface=eth0
dhcp-range=192.168.6.8,192.168.6.250,255.255.255.0,12h
Edit /etc/sysctl.conf and uncomment this:

Code: Select all

net.ipv4.ip_forward=1
My iptables rule.

Code: Select all

sudo iptables -t nat -A  POSTROUTING -o wlan0 -j MASQUERADE
Then make the iptables rule permanent.

Code: Select all

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Then in /etc/rc.local, add this:

Code: Select all

iptables-restore < /etc/iptables.ipv4.nat
If you are using a bridge, you don't need dnsmasq as per the online docs.
https://www.raspberrypi.org/documentati ... s-point.md
Look for the section on the bridge setup about 2/3 down the page.
Using the Raspberry Pi as an access point to share an internet connection (bridge)

n67
Posts: 938
Joined: Mon Oct 30, 2017 4:55 pm

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Thu Mar 01, 2018 2:46 pm

Note that you probably don't need dnsmasq in any case. I prefer not to install "yet more software" if I don't think I need it - more stuff to learn; more stuff to deal with, etc, etc.

Instead, use busybox (which is already there in Raspbian) and includes (among many, many other things) a dhcp server (udhcpd) and works quite well.
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Thu Mar 01, 2018 3:12 pm

razor wrote:
Thu Mar 01, 2018 2:28 pm
hard to find definitive answers in this thread... :)

Why do i need to use dnsmasq?
I want to use Raspi as a bridge (i guess that's a proper name), to connect device that doesn't have wifi to my local wifi network (wifi router). i want this device to acquire IP from wifi router dhcp.
Because the title of this thread is now slightly misleading, it's setting the pi up as a router rather than a bridge. The reason for this is that the wifi standard doesn't support multiple devices (i.e. the pi and your other device) on the client side of the connection. You could try setting up a bridged connection between the wifi device and ethernet but I'm not sure the OS will let you, and if it does allow it you may find odd effects as both the pi and other device will appear to be the same device to the router.

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Thu Mar 01, 2018 3:18 pm

mfa298 wrote:
Thu Mar 01, 2018 3:12 pm
Because the title of this thread is now slightly misleading, it's setting the pi up as a router rather than a bridge. The reason for this is that the wifi standard doesn't support multiple devices (i.e. the pi and your other device) on the client side of the connection. You could try setting up a bridged connection between the wifi device and ethernet but I'm not sure the OS will let you, and if it does allow it you may find odd effects as both the pi and other device will appear to be the same device to the router.
You can set up a bridge between an ethernet interface and a wireless access point. It works fine. Been there. Done that. I use a second wireless device as the WAN interface to the internet.

You cannot set up a bridge between a wireless client and any other interface. The OS throws a "Operation not permitted" error.

juhnke
Posts: 1
Joined: Wed Apr 25, 2018 1:59 pm

Re: How To: Wifi to Ethernet Bridge(Updated for RPi 3)

Wed Apr 25, 2018 2:01 pm

Trying to earn my necromancer badge. This tutorial (the script specifically) works great on a RPi Model B with a USB wifi adapter.

https://nke.me/2vPGcZA

JohnEdens
Posts: 1
Joined: Wed Apr 25, 2018 9:26 pm

A scenario very close to one described...

Wed Apr 25, 2018 10:29 pm

I have a scenario that I'm trying to make happen that I think is very close to what SurferTim described here:

viewtopic.php?f=36&t=132674&start=50#p1252309

The main differences are that I'm using static addresses and am working in a WAN environment.

I run a security camera system across a campus. Our network department has assigned me approximately 1000 IP addresses in the range of xxx.yyy.2.zzz - xxx.yyy.5.zzz and assign static addresses to the cameras as I install them.

Normally I just run a cable from the camera to the local switch in the building where the camera is located, then let Networking know the MAC of the new camera and which switch I put it on. They then take that port and put it on a VLAN so that I can access that camera over the WAN from my central location and capture the video.

However, I now need to set up a camera system in a building that is both historical and used as a museum. So running cable is not possible and besides they want to be able to move the cameras around as different exhibits are set up and taken down.

The obvious solution would be dedicated wireless cameras, however this is thought to be too expensive.

I have tried using usb cameras with the Pi and streaming video that way, however I found that the wireless connection would drop after a few hours.

So what I want to try next is to take a wired IP camera and plug it into eth0 and stream that video via wlan0 to the buildings wireless access point.

I think the above referenced link is similar to what I want, however I won't be using DHCP and am not sure from the instructions at the link how this would work with static IP addresses. I'm also not sure whether or not I would need three different static IPs in this setup, one for the camera, one for eth0 and one for wlan0.

If SurferTim or anyone else could advise, I would appreciate it.

Return to “Networking and servers”