Updated Cluster HAT images (based on Raspbian Stretch with Desktop/Lite 2018-03-13)
Changes
=======
Along with the normal Controller image which use bridging I have created a new NAT image which doesn't bridge the Ethernet on the Controller Pi but uses NAT which can be used for both WiFi and Ethernet sharing.
Details of the new NAT image
============================
Due to what looks like a bug in the Pi3+ Ethernet driver adding the Pi3+ built in Ethernet device (eth0) to a bridge causes a kernel oops (https://github.com/raspberrypi/linux/issues/2437) and boot never gets to a login prompt! (This will also be a problem for those using the Pi3+ as a bridged Access Point)
To work around this problem on the Cluster HAT I've released the Controller NAT (Network Address Translation) Lite and Desktop [still uploading] images for both WiFi and Pi3+ users. We're keeping the standard bridged Controller and P1/P2/P3/P4 images for those not using a Pi3+.
The downside if using the new NAT configuration is you will no longer be able to log into the Pi Zeros directly from the local network (via WiFi or Ethernet). You must first log into the controller and then to Pi Zeros. If you need to access the Pi Zeros directly you could add iptables rules or use ssh port forwarding to forward connections via the Controller to the Pi Zero.
As with all of the other types of image (Controller/P1/P2/P3/P4/etc.) using the "Intermediate" setup you can reconfigure a Cluster HAT 2018-03-14 image to use NAT or the standard bridged network by appending " quiet init=/sbin/reconfig-clusterhat cnat" or " quiet init=/sbin/reconfig-clusterhat c".
Network configuration on the NAT (cnat) image
=============================================
ethpi1/ethpi2/ethpi3/ethpi4/etc. are still automatically bridged with br0
BUT eth0 on the controller is NOT added to the bridge br0 on boot (this is the step which causes the Oops).
Pi Zeros are assigned the IP 172.19.181.X where X is the P number (P1=172.19.181.1, etc) and the Controller br0 interface is assigned 172.19.181.254.
NAT:When using with Ethernet
============================
Allows eth0 to either be configured with DHCP from the local network as normal or you can add a static IP address for eth0 to "/etc/dhcpcd.conf" see the commented out "interface eth0" section, connections from the Pi Zeros will use nat on the Controller to access the network/internet via the Controllers internet connection.
NAT:When using with WiFi
========================
When using WiFi you need to configure the wireless as normal either by placing a wpa_supplicant.conf in the boot partition or using the command line. Again connections from the Pi Zeros will use nat on the Controller to access the network/internet via the Controllers internet connection.
# Sample wpa_supplicant.conf file, replace GB with your 2 letter country code.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB
network={
ssid="YourSSID"
psk="YourPSK"
}
NAT:When using standalone
=========================
When no Ethernet/WiFi is available the Pi Zeros will still have IPs 172.19.181.X (where X is the P number) and 172.19.181.254 on the Controller br0 which allows communication between controller/zero an zero to zero.
Upgrade
=======
Then upgrade the Pi Zeros
# Run on each Pi Zero
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get -y install subversion
echo 'iptables-persistent iptables-persistent/autosave_v4 boolean false' | debconf-set-selections
echo 'iptables-persistent iptables-persistent/autosave_v6 boolean false' | debconf-set-selections
APT_LISTCHANGES_FRONTEND=none apt-get -y install iptables-persistent
echo '#net.ipv4.ip_forward=1 # Cluster HAT NAT' >> /etc/sysctl.conf
cat << EOF >> /etc/iptables/rules.v4
# Generated by iptables-save v1.6.0 on Fri Mar 13 00:00:00 2018
*filter
:INPUT ACCEPT [7:1365]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A FORWARD -i br0 ! -o br0 -j ACCEPT
-A FORWARD -o br0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Fri Mar 13 00:00:00 2018
# Generated by iptables-save v1.6.0 on Fri Mar 13 00:00:00 2018
*nat
:PREROUTING ACCEPT [8:1421]
:INPUT ACCEPT [7:1226]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Fri Mar 13 00:00:00 2018
EOF
cat << EOF >> /etc/dhcpcd.conf
# ClusterHAT
denyinterfaces eth0 ethpi1 ethpi2 ethpi3 ethpi4
profile clusterhat_fallback_usb0
static routers=172.19.181.254
static domain_name_servers=8.8.8.8 208.67.222.222
profile clusterhat_fallback_br0
interface usb0
fallback clusterhat_fallback_usb0
interface br0
fallback clusterhat_fallback_br0
EOF
On P1 append " quiet init=/sbin/reconfig-clusterhat p1" to the end of the cmdline.txt file in /boot (keeping it all on one line) and shutdown (repeat changing "p1" to p2/p3/p4 and then c for the other installations).
Then update the Controller
# Run on the Controller
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get -y install subversion
echo 'iptables-persistent iptables-persistent/autosave_v4 boolean false' | debconf-set-selections
echo 'iptables-persistent iptables-persistent/autosave_v6 boolean false' | debconf-set-selections
APT_LISTCHANGES_FRONTEND=none apt-get -y install iptables-persistent
echo '#net.ipv4.ip_forward=1 # Cluster HAT NAT' >> /etc/sysctl.conf
cat << EOF >> /etc/iptables/rules.v4
# Generated by iptables-save v1.6.0 on Fri Mar 13 00:00:00 2018
*filter
:INPUT ACCEPT [7:1365]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A FORWARD -i br0 ! -o br0 -j ACCEPT
-A FORWARD -o br0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Fri Mar 13 00:00:00 2018
# Generated by iptables-save v1.6.0 on Fri Mar 13 00:00:00 2018
*nat
:PREROUTING ACCEPT [8:1421]
:INPUT ACCEPT [7:1226]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Fri Mar 13 00:00:00 2018
EOF
cat << EOF >> /etc/dhcpcd.conf
# ClusterHAT
denyinterfaces eth0 ethpi1 ethpi2 ethpi3 ethpi4
profile clusterhat_fallback_usb0
static routers=172.19.181.254
static domain_name_servers=8.8.8.8 208.67.222.222
profile clusterhat_fallback_br0
interface usb0
fallback clusterhat_fallback_usb0
interface br0
fallback clusterhat_fallback_br0
EOF
Append " quiet init=/sbin/reconfig-clusterhat c" to the end of the cmdline.txt file in /boot (keeping it all on one line) and reboot or if you want to switch to the new NAT configuration append " quiet init=/sbin/reconfig-clusterhat cnat" instead.
Please remember the "c" configuration will not work on a Raspberry Pi B 3+, the "cnat" image will work on any (A+/B+/2/3/3+).
======