How do I setup NAT on the WiFi interface on the rpiboot test images?
WARNING: These steps relate to the OLD test rpiboot (only) images and NOT the current combined images, if you want NAT on the current image just switch the type to cnat (see Intermediate tab on https://clusterctrl.com/setup-software to switch from CBRIDGE).
Setup the wireless connection as normal by following the documentation.
Install the package to allow saving the iptables rules, say no to saving existing ipv4/ipv6 rules as you won't have any.
sudo apt-get -y install iptables-persistent
Add a default gateway to the IP configuration for the Pi Zeros
sudo sed -i "s/172.19.180.254::255.255.255.0/172.19.180.254:172.19.180.254:255.255.255.0/" /var/lib/clusterhat/nfs/p*/boot/cmdline.txt
Enable IPv4 forwarding
sudo sh -c "echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf" sudo sysctl -p /etc/sysctl.conf
Setup and save the NAT rules for traffic from the Pi Zero internal network range.
sudo iptables -t nat -A POSTROUTING -s 172.19.180.0/24 ! -o brint -j MASQUERADE sudo iptables -A FORWARD -i brint ! -o brint -j ACCEPT sudo iptables -A FORWARD -o brint -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT sudo sh -c "iptables-save > /etc/iptables/rules.v4"
You should now be able to power up the Pi Zeros and access the internet through the wifi connection on the controller.