I have the following situation

enter image description here

I would like to make the Internet connection on wlan0 of the Pi available to all devices connected on eth0. I'am using Raspian Stretch, predictable network interface names disabled, /etc/network/interfaces is empty, ip4 forwarding enabled, /etc/dhcpcd untouched.

The Pi receives the eth0 config from the LAN side DHCP Server and the wlan0 config from the AP "Router".

Following several tutorials here and elsewhere routing traffic from eth0 to wlan0 should be straightforward. See, for example, this post eth0 to wlan0 NAT router setup?, this one eth0 to wlan0 NAT router [duplicate] or this Cent OS based solution CentOS / Redhat Linux Internet Connection Sharing.

  • SSID1: Subnet GW: (on Router in Image)
  • SSID2: Subnet GW: (on PI:eth0)
  • Host1: on Subnet GW: (on Router in image)

Unfortunately, none of those solutions which are basically all the same seem to work in the case abvove.

Core step is route traffic from eth0 to wlan0 using iptables

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

I am able to do this:

  • ping or access Host1 from by webbrowser

I am not able to access any host on the internet from or from the Pi itself

Looks like a gateway or a route is missing? The result of ip route

$ip route
default via dev eth0 src metric 202
default via dev wlan0 src metric 303 dev eth0 proto kernel scope link src metric 202 dev wlan0 proto kernel scope link src metric 303

Now I am at an end with my knowledge, what is missing and what should/could I do? Any help would be appreciated.

  • In your picture the ip address is the same then GW= This isn't possible. What is AP "Router"? What subnet has wifi with ssid "SSID1"? What subnet has wifi with ssid "SSID2"? To what subnet belongs Host1? To what subnet belongs Test1? Please edit your question to update it.
    – Ingo
    Aug 17, 2018 at 13:43
  • What is the output of ip route on the Pi? Aug 17, 2018 at 14:08
  • As has already been pointed out, and it case it was not clear enough, both networks set up "around" the wlan router are the same (192.168.2/24, I presume). Set it up so that you don't have duplicate network segments on any of the 3 networks shown there (SSID1, SSID2, pi to WLAN Router) and everything should start working fine.
    – eftshift0
    Aug 17, 2018 at 18:03
  • My intention ist have only one Subnet on the right hand side of the Pi, ie. The fact that there is another WLAN with SSID "SSID2" should be irrelevant. I can switch off "SSID2", connect all client through cable and have the same result.
    – bscwuenn
    Aug 18, 2018 at 6:16
  • The problem is not the name of the wireless networks. It's that the WLAN ROUTER has two overlapping network segments set up (both segments are Take one of the segments and set it to, for example). Also, I see another problem with the pi set up It's displaying two "default" GW. That can't be good (and will probably make it misbehave) so this line should be gone default via dev eth0 src metric 202.
    – eftshift0
    Aug 18, 2018 at 9:13

1 Answer 1


I have been able to solve this problem withe the help of the comments. First i have disabled the wlan "SSID2". So the eth0 interface of the pi faces exactly one subnet Alle devices are connectet using cables and a switch with dhcp cababilities. The output of

> ip route  

showed a default route for eth0 (added automatically by dhcpdcd)

Sudo ip route del 0/0 dev eth0  

got rid of that entry and as soon as i enabled routing by

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

the system worked as desired. Case closed, Thank you.

  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Apr 1, 2020 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.