Is there a guide to setup a RPiB3 with Raspbian Stretch as a eth0 to wlan0 NAT-router?

I have tried eth0 with a fixed IPAddress and DHCP host for attached equipment. Using dnsmasq or isc-dhcp

$ sudo vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
$ sudo iptables -t nat -A POSTROUTING -s -o wlan0 -j MASQUERADE

Wlan0 as fix IPAddress or obtaining an IP Address from the local network router.

Using a laptop on eth0 to test the setup, the best I can do is “see” local network servers, like an APC UPS web interface. This set up will not allow access through the local router to the internet. However, the RPi shows as connected to the local router.

I am not sure if avahi, the local router, or just a bad setup is the problem. A guide would be really helpful.


I think you need something more like:

iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
ip addr add dev eth0

You may not need/want the last line if you've set up a DHCP service (just assigning the CIDR will work without DHCP if the connected devices set their own static IP and default route). I'm presuming based on your question that 192.168... refers to the subnet you are creating and not the WLAN the Pi is on.

A guide would be really helpful.

There are probably umpteen guides to this if you use "linux" in your search terms instead of "Raspberry Pi" or "Raspbian". The brand of hardware is irrelevant. The specific distro may matter a bit, but in that case using "Debian" would be better.

  • Exceeded comment character limit. Posting new question.
    – tflemer
    Feb 24 '18 at 22:48
  • This worked for me but I used -A instead of -D. -D is listed in the iptables documentation as being used to delete a rule so I'm not sure why you suggested it here. Dec 13 '18 at 3:44

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