Raspberry Pi Asked by Danny Herbert on January 19, 2021
I currently have a raspberry pi4B (p0
) with four raspberry pi Zeros (p1-4
) all conected to the pi0
via USB (using usb gadget mode for a network connection). To be specific i’m using a pi Cluster Hat.
At the moment the p0
has an IP on my home network of 192.168.1.86
. p1-4
have IPs of 172.19.181.1-4
.
Accessing p1-4
from p0
via the network using their IPs works perfectly. However if I want to access p1-4
from another desktop computer desk
then they don’t show on the home network. From what I’ve read this makes sense, as the 172.19.181.x
part of the IP of the p1-4
defines a new sub net that can’t be accessed from outside.
My mental image of how these interconnect is this (not sure if correct):
My question is: is there a way that I can have desk
communicate directly with p1-4
? is the whole p0
and p1-4
system considered it’s own sub network even though there is no seperate router between?
Also, how do the raspberry pis all behave if I remove them from the router’s network? Right now the router assigns the p0
an IP of 192.168.1.86
which p1-4
use in order to communicate with it, whereas the p1-4
always have their IP’s the same (172.19.181.1-4
). For now I want to have all the pis on the home network for development, but will eventually want to remove the pi’s (0-4) from the network and still have them be able to communicate without worrying about p0
having it’s IP reassigned. Is this possible?
This is a usual routing problem as used all over the world on the internet. You have two subnets, 192.168.1.0/24
and 172.19.181.0/24
(the bitmasks /24
are assumed. They are mostly used). All router on your network have to know to which next hop it has to send packages, to get to the destination subnet. The router
must know that it has to send packages with destination 172.19.181.0/24
to p0
, its next hop. So you have to set a static route on the router
. I don't know your router, so I can't say how to do it. Have a look at its configuration options. You must set a static route with destination network to 172.19.181.0/24
(or 172.19.181.0
netmask 255.255.255.0
) and its corresponding gateway (next hop) to 192.168.1.86
, the ip address of p0
. On a Linux system this would be set with:
router ~$ sudo ip route add 172.19.181.0/24 via 192.168.1.86
Because p0
is working as (another) router now to the subnet 172.19.181.0/24
, it is a bad idea that it has a dynamic ip address. If its ip address is changed by the DHCP server then you have to reconfigure all static routes to it on the network. So it is strongly recommended to give it a static ip address. Be sure that this ip address is not in the ip address pool of the DHCP server that it will give dynamically to devices on the network. As default gateway set the ip address of router
. You also have to enable ip forwarding, so packages from subnet 172.19.181.0/24
are forwarded to subnet 192.168.1.0/24
. This is done with:
rpi ~$ echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
But this is only transient. On reboot it is lost. Look at your operating system how to set it persistent. On a RaspiOS you uncomment #net.ipv4.ip_forward=1
in /etc/sysctl.conf
.
A static ip address also answers your second question. You can disconnect p0
from the network without loosing connection to pi1-4
.
Correct answer by Ingo on January 19, 2021
the "router" in your image is most likely a switch. It may be a switching part of an Internet router but it is (probably) still a switch.
I have never used a clusterhat, but as I understand it, there are two ways of configuring the network:
As I understand it, these are different images for the nodes.
It is possible to set-up IPtable rules on the cluster controller if you use CNAT images. This will require a bit of tweaking. Also, you will probably need to set-up a static route on your desktop. If you've never done this, you should probable use CBRIDGE images.
Answered by Ljm Dullaart on January 19, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP