davethomaspilot
Posts: 104
Joined: Tue Apr 29, 2014 6:18 pm

Internet access for ethernet connected RPI network-- Stretch, 3b,3b+

Tue Feb 19, 2019 3:28 pm

I have a network of ethernet connected network of rpis with static ips.

May not be relevant, but one of the rpis is set up as a wireless hotspot with a bridge using what I think is Surfer Tim's tutorial:

https://thepi.io/how-to-use-your-raspbe ... ess-point/

After trying LOTS of different tutorials and slight changes, I got it to work like I wanted.
I had to change the dnsmasq.conf file to use br0 instead of wlan0 for the dhcp interface:

Code: Select all

log-dhcp
interface=br0
  dhcp-range=192.168.173.5,192.168.173.70,255.255.255.0,24h
and an entry in dhcpcd.conf for a static br0 interface:

Code: Select all

interface br0
static ip_address=192.168.173.11/24
static routers=192.168.173.21
static domain_name_servers=8.8.8.8 8.8.4.4
(Before I changed dnsmasq.conf to use br0, wifi connected clients got a 169.x.x.x ip)

Now a wifi connected client gets an ip address and I can ssh connect over wifi to any the ethernet connected rpis!

Now, I want to go one step further and have a different rpi in the ethernet connected network be a wifi client and be a gateway for the ethernet connected pis to use for internet access.

One of the rpis is configured to be a client. It connects to the wifi router and can ping 8.8.8.8. I use its ip address as the router for the other ethernet connected rpis, (192.168.173.21) they can't access the internet.

The ethernet connect rpis CAN ping each other.

What do I need to do for the ethernet connected rpis so they can access the internet through the one wifi client coonected rpi?

davethomaspilot
Posts: 104
Joined: Tue Apr 29, 2014 6:18 pm

Re: Internet access for ethernet connected RPI network-- Stretch, 3b,3b+

Tue Feb 19, 2019 4:08 pm

Ok, got it working. Caveat--I don't really understand this stuff, it's just "Monkey read, monkey do".

I borrowed the iptables setup that I see in this script:

https://github.com/arpitjindal97/raspbi ... h-route.sh
sudo iptables -F
sudo iptables -t nat -F
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
#sudo iptables -A FORWARD -i $wlan -o eth0 -m state --state RELATED,ESTABLISHED$
sudo iptables -A FORWARD -i etho -o wlan0 -j ACCEPT

After uncommenting the net.ipv4.ip_forward = 1 in /etc/sysctl.conf and then exeucting the iptables commands, ethernet connected rpis can now access the internet through the one wlan client connected rpi.

epoch1970
Posts: 3694
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Internet access for ethernet connected RPI network-- Stretch, 3b,3b+

Tue Feb 19, 2019 4:22 pm

davethomaspilot wrote:
Tue Feb 19, 2019 3:28 pm
May not be relevant, but one of the rpis is set up as a wireless hotspot with a bridge using what I think is Surfer Tim's tutorial:

https://thepi.io/how-to-use-your-raspbe ... ess-point/
This "guide" is ludicrously wrong. The guy first sets up routing/masquerade and then nixes it by bridging everything... He missed copy-pasting a main section title in the docs he used as "inspiration".

There is an official howto: https://www.raspberrypi.org/documentati ... s-point.md
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Networking and servers”