1

I have a project where I have 4x RPiZ plugged into a single RPi4. The RPiZs appear as Ethernet over USB devices as network interfaces ethpi1, ethpi2,ethpi3, and ethpi4 with IP addresses 10.0.11.2, 10.0.12.2, 10.0.13.2, and 10.0.14.2 respectively. The RPi4 is on a network I have access to with a known, but not controlled, IP address like 192.168.0.2 or something. I won't have physical access to the device once it is set up. All 5x RPi's have a FTP (proftpd) server, a HTTP (lighttpd) server, and SSH enabled.

I am trying to figure out how to access these servers on the RPiZ's without first SSHing into the RPi4. This involves multiple related questions. If I have a computer on the same ethernet network as the RPi4, how do I direct traffic to/from the RPiZ's?

2

This is more a common routing issue than belonging specifically to Raspberry Pi. Anyway, here are the manual routing settings because I don't know what operating system and what networking service do you use. Look how to set it persistent on your setup.

We have one local area network 192.168.0.0/24 (bitmask /24 assumed because you don't tell it) and will assume that the RPi 4B is connected to it with ip address 192.168.0.2/24 on its interface. This ip address must be static because we will use it as gateway interface that must be known. I also assume that all RPi Zero have its default route set to the RPi 4B (that's usually default). The RPi 4B is acting as a router and it knows where to send ip packets because the devices are all direct connected to it. I also assume that it has a default route to the internet router on the local network so it can get into the internet.

On the RPi 4B you have to set ip forwarding so that ip packages can be forwarded to the other interfaces if needed:

rpi4b ~$ sudo sysctl net.ipv4.ip_forward=1

If you can get into the internet on the management console (the computer on the local network 192.168.0.0/24) it has its default route also set to the internet router on the local network. You have to tell it to use the RPi 4B as default gateway instead:

mgmnt ~$ sudo ip -4 route del default
mgmnt ~$ sudo ip -4 route add default via 192.168.0.2/24

You should now be able to ping all devices and get into the internet. The internet connection is routed now by the RPi 4B because its default route is set to the internet router on the local network.

1
  • This is so great! It works perfectly. On a mac the command is sudo route add 10.0.0/24.0/24 192.168.0.2. It forwards all traffic like you said so everything just works cleanly now. Thank you @Ingo.
    – Rusty
    Jan 21 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.