Multiple Raspberry Pi Zero g_ether gadgets.

My notes for connecting multiple pi zero nodes to a single pi 2/3 host.

See the e.g. notes, for each node we will be incrementing the host names, mac addresses, and ip subnets.

On the host.

Enable ipv4 forwarding and iptables NAT.
Run ssh-keygen to create and populate the ~/.ssh folder.

For each node.

Add entry to /etc/udev/rules.d/90-cluster.rules.
(e.g. use 00:22:82:ff:ff:02 and ethpi2 for the next one.)

SUBSYSTEM=="net", ATTR{address}=="00:22:82:ff:ff:01", NAME="ethpi1"

Add entry to /etc/network/interfaces.
(e.g. use ethpi2, 10.0.2.100, 10.0.2.0 and 10.0.2.255 for the next one.)

allow-hotplug ethpi1
iface ethpi1 inet static
address 10.0.1.100
netmask 255.255.255.0
network 10.0.1.0
broadcast 10.0.1.255

On each node.

Use raspi-config to change the hostname and expand the file system.
Run ssh-keygen to create and populate the ~/.ssh folder.
Append the host machines ~/.ssh/id_rsa.pub to the nodes ~/.ssh/authorized_keys
Add modules to /boot/cmdline.txt on the same line after rootwait.
(e.g. use 00:22:82:ff:ff:02 and 00:22:82:ff:ff:12 for the next one.)

modules-load=dwc2,g_ether g_ether.host_addr=00:22:82:ff:ff:01 g_ether.dev_addr=00:22:82:ff:ff:11

Add overlay to bottom /boot/config.txt.

dtoverlay=dwc2p

Add entry to bottom of /etc/dhcpcd.conf
(e.g. use 10.0.2.10 and 10.0.2.100 for the next one.)

interface usb0
static ip_address=10.0.1.10
static routers=10.0.1.100
static domain_name_servers=8.8.8.8