So I am following the recipe below using Raspberry OS Buster Lite:
I can connect my laptop to the Pi (hostapd works) and obtain an IP without a problem (dhcp works), and I can also connect to it via SSH, but the routing part is not working (I cannot ping the Internet).
The single line below doesn't seem to work:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
and the command below complains about iptables-legacy being present:
sudo netfilter-persistent save
I suspect that the recent change to iptables using nftables is the culprit why this recipe doesn't work. But some other sources suggest to use the routing commands below so I don't really know:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
Add the fact that this recipe edits /etc/sysctl.d/routed-ap.conf and other sources edit /etc/sysctl.conf makes matter even more confusing.
Also there are other ways to make the routing persistence than the one presented in the recipe:
- Make a bash script into a systemd service and use systemctl.
- Make a bash script run from /etc/rc.local using iptables-restore.
Will some network/routing guru please shed some light into this confusing matter and just say what's the best practice for this newbie sysadmin? Thanks!