briantoby
Posts: 5
Joined: Sun Oct 14, 2018 1:44 am

Problem with "Wifi to Ethernet Bridge" HowTo -- solved!

Sun Oct 14, 2018 2:20 am

Since the How To: Wifi to Ethernet Bridge (Updated... https://www.raspberrypi.org/forums/view ... 74#p884243 has gotten so big and fragmented, I thought it best to start a new thread. Note this is not actually using an ethernet bridge -- since the connection uses NAT to bring packets from one network to another.

I have tried following that recipe, but I am finding that the /etc/network/interfaces has changed for Raspbian 9 (stretch), on a Pi3B+. The only non-comment line in that file is this

Code: Select all

source-directory /etc/network/interfaces.d
and if I add

Code: Select all

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
as called for, then eth0 is started with DHCP running properly, but wlan0 does not get configured and does not show up in ifconfig. I have tried adding various permutations to /etc/network/interfaces to also configure wlan0, but the only thing I have found that allows wlan0 to be configured is to comment out the lines above for eth0.

I would love some advice on how to get this configured so that wlan0 is functioning with eth0 running.

Before asking about this I spent a lot of time reading web pages and am reluctantly thinking that what I want to achieve is not likely to work. I have a dedicated wifi router that I use to serve a printer connection to a tablet & laptop. I was hoping to use the RP to bridge in a connection to a local wifi hotspot that provides and internet connection (rather than connecting the router on a modem), so that on a single network the devices can print and surf. I am beginning to suspect that this type of IP masking is not possible, though I was able to do something like this with Windows bridging/sharing. If anyone is sure one way or the other, it would sure be helpful to know.

Thanks in advance for your help, Brian
Last edited by briantoby on Mon Oct 15, 2018 1:58 pm, edited 3 times in total.

briantoby
Posts: 5
Joined: Sun Oct 14, 2018 1:44 am

Re: interfaces problem with Wifi to Ethernet Bridge HowTo

Sun Oct 14, 2018 4:19 pm

I have gotten farther on this after much reading. I added this to /etc/network/interfaces:

Code: Select all

auto wlan0
#allow-hotplug wlan0
iface wlan0 inet dhcp 
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf 
Now my wlan0 connection comes up and my ethernet port is live granting addresses via dchp. I can ssh into the RP. There does not appear to be any connection between the ports. If I ping something on the net (say 8.8.8.8 from the RP it works fine, but not from a computer on the secondary network via eth0.

I must be missing something. Bridging?

briantoby
Posts: 5
Joined: Sun Oct 14, 2018 1:44 am

Re: interfaces problem with Wifi to Ethernet Bridge HowTo

Sun Oct 14, 2018 4:54 pm

Farther: the "bridging" problem is that the IP tables update is not getting done on boot. If I run the

Code: Select all

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
command manually, then everything works! (!!!!) Speeds seem great, particularly compared to when I tried to do this on Windows (which was flakey as well as slow)

Likewise running the dhcpcd hook manually after a boot also works (after doing a chmod on it)

Code: Select all

sudo /lib/dhcpcd/dhcpcd-hooks/70-ipv4-nat
but

Code: Select all

sudo iptables-save
is empty right after a boot.

A hint for me is in /var/log/boot.log:
FAILED Failed to start dhcpcd on all interfaces.
See 'systemctl status dhcpcd.service' for details.
and the systemctl command shows this:
● dhcpcd.service - dhcpcd on all interfaces
Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-10-14 11:40:46 CDT; 8min ago
Process: 386 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b (code=exited, status=6)

Oct 14 11:40:46 bridgepi systemd[1]: Starting dhcpcd on all interfaces...
Oct 14 11:40:46 bridgepi dhcpcd[386]: Not running dhcpcd because /etc/network/interfaces
Oct 14 11:40:46 bridgepi dhcpcd[386]: defines some interfaces that will use a
Oct 14 11:40:46 bridgepi dhcpcd[386]: DHCP client or static address
Oct 14 11:40:46 bridgepi systemd[1]: dhcpcd.service: Control process exited, code=exited status=6
Oct 14 11:40:46 bridgepi systemd[1]: Failed to start dhcpcd on all interfaces.
Oct 14 11:40:46 bridgepi systemd[1]: dhcpcd.service: Unit entered failed state.
Oct 14 11:40:46 bridgepi systemd[1]: dhcpcd.service: Failed with result 'exit-code'.
Now if only I knew enough to figure out how to sort through this, I might be done. Help would be great.

Not sure why dhcpcd is even needed here.

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

Re: interfaces problem with Wifi to Ethernet Bridge HowTo

Sun Oct 14, 2018 5:44 pm

If you want a bridge, use the second example here:
https://www.raspberrypi.org/documentati ... s-point.md

briantoby
Posts: 5
Joined: Sun Oct 14, 2018 1:44 am

Re: interfaces problem with Wifi to Ethernet Bridge HowTo

Mon Oct 15, 2018 3:42 am

Got this working, finally!

I did not want to figure out how to get dhcpcd to run (in fact, I uninstalled the package since it is not needed).

I moved the

Code: Select all

iptables-restore < /etc/iptables.ipv4.nat
command into /etc/rc.local as the 2nd to last line (before exit 0) and done! On boot, the wlan0 port connects to the hotspot, the eth0 port gives my router a IP address and uses NAT translation. The RP does a good job of forwarding packets and at least with a light load, any latencies were too small for me to notice.

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

Re: interfaces problem with Wifi to Ethernet Bridge HowTo -- solved!

Mon Oct 15, 2018 11:59 am

OK, so you are using a standalone (NAT) AP. That would have been the first example. Your subject line was misleading.

briantoby
Posts: 5
Joined: Sun Oct 14, 2018 1:44 am

Re: Problem with "Wifi to Ethernet Bridge" HowTo -- solved!

Mon Oct 15, 2018 2:07 pm

@SurferTim: Thanks for pointing out how this was misleading.

The title was selected to reference the HowTo I was trying to use, which also used the word bridge. I have modified the title a bit to make the topic reference more clear -- I hope -- and put some explanatory text into the initial entry. I should note that went into this not knowing if a bridge was what I wanted. I now understand it would not have worked, I needed the NAT layer to connect two different networks (as well as provide a firewall).

mohammedshafit
Posts: 1
Joined: Fri Nov 02, 2018 7:02 am

Re: Problem with "Wifi to Ethernet Bridge" HowTo -- solved!

Fri Nov 02, 2018 7:06 am

Hi, I am looking for the same what you have accomplished here.
Can you please consolidate the steps you have done. That would be a great help for newbies like me.

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

Re: Problem with "Wifi to Ethernet Bridge" HowTo -- solved!

Fri Nov 02, 2018 12:21 pm

mohammedshafit wrote: Hi, I am looking for the same what you have accomplished here.
Can you please consolidate the steps you have done. That would be a great help for newbies like me.
Consider it done.
https://www.raspberrypi.org/documentati ... s-point.md

Return to “Networking and servers”