Networking - cjus/hydra-cluster GitHub Wiki

IMPORTANT: This section provides networking tips for configuring the cluster's two Pi 3s - it does not apply to the configuration for the third Pi 3 which is acting as a controller for the four Pi Zeros using a ClusterHat. That configuration follows.

When you first setup a Raspberry Pi (after flashing the SD card) you should it directly to your router directly using an Ethernet cable.

After starting the PI you should be able to find it by ping raspberrypi.local to see at what IP address it resolves.

$ ping raspberrypi.local
PING raspberrypi.local (192.168.1.218): 56 data bytes
64 bytes from 192.168.1.218: icmp_seq=0 ttl=64 time=3.997 ms
64 bytes from 192.168.1.218: icmp_seq=1 ttl=64 time=2.178 ms

You can then ssh into your Pi using the default pi/raspbrerry credentials.

$ ssh [email protected]
The authenticity of host '192.168.1.218 (192.168.1.218)' can't be established.
ECDSA key fingerprint is SHA256:ZLF6F2E8NXVupKxtYaAYm5YFi84xFQYLMsN5XGDkLXk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.218' (ECDSA) to the list of known hosts.
[email protected]'s password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
pi@raspberrypi:~ $

You're now ready to reconfigure the networking settings.

However, don't forget to configure your Pi by at least changing its default password. Use sudo raspi-config.

Next, we'll use standard Debian networking. This will provide static IP addresses for each cluster node.

$ cd /etc/network
$ sudo vi interfaces

The 192.168.1.x space is used in this doc because that's the network address scheme for my home network. Yours may differ.

Change the line that reads: iface eth0 inet manual to:

auto eth0
iface eth0 inet static
  address 192.168.1.10
  netmask 255.255.255.0
  gateway 192.168.1.1
  dns-nameservers 8.8.8.8 8.8.4.4

The 192.168.1.10 address above should be different for each Pi.

Next disable DHCPCD and switch to Debian networking:

$ sudo systemctl disable dhcpcd
$ sudo systemctl enable networking

Lastly, sudo reboot to apply the settings on the next restart.

Ad hoc networking via a Mac

You can connect (ssh) to each Pi in the cluster by using ad hoc networking on your computer.

Then you can ssh into each Pi:

$ ssh [email protected]

Computers

Node Use IP
00 Redis, Hydra-router, Hydra-mcp 192.168.1.10
01 Monitor, constats 192.168.1.11
02 ClusterHat 192.168.1.12
03 Zero 1 192.168.1.13
04 Zero 2 192.168.1.14
05 Zero 3 192.168.1.15
06 Zero 4, pilights 192.168.1.16

ClusterHat Setup

The ClusterHat is a controller which allows the hosting of four Raspberry Pi Zeros. To do this it allows the Zeros to be networked over onboard USB connections using a bridged network.

For more about bridged networks see BridgeNetworkConnections

Configuring the controller for use requires modifying the networking configuration on the host Raspberry Pi (controller) and each of the connected Pi Zeros.

Firstly, setup the ClusterHat using the instructions found here

Then perform the following post configurations.

Controller Setup

While working with the ClusterHat I found it useful to be able to switch from DHCP and Static networking. To facilitate this I created two files to backup the configuration for each mode.

$ cd /etc/network
$ sudo cp interfaces interfaces.dhcp
$ sudo cp interfaces interfaces.static

Then I edited the interfaces.static by simply replacing the iface br0 inet entry with:

iface br0 inet static
  bridge_ports eth0
  bridge_stp off
  bridge_waitport 0
  bridge_fd 0
  address 192.168.1.12
  broadcast 192.168.1.255
  netmask 255.255.255.0
  network 192.168.1.0
  gateway 192.168.1.1
  dns-nameservers 8.8.8.8 8.8.4.4

To switch between DHCP and Static I just do:

$ sudo cp interfaces.static interfaces

or

$ sudo cp interfaces.dhcp interfaces

Pi Zeros Setup

Each Pi Zero needs to be updated to create a secondary network interface to provide a static IP. A hat tip to Ken Darker for his excellent post.

$ cd /etc/network
$ sudo vi interfaces

Append:

auto usb0:0
allow-hotplug usb0:0
iface usb0:0 inet static
  address 192.168.1.13
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255

Increment above address for each new node.

This allows each Pi Zero to work in the mode (dhcp / static) specified by the host Pi.