I had an idea for transferring data between Pi's. It involves directly connecting two Pi's to each other only using a single cat5 ethernet cable, and transferring data in a peer to peer manner. I have a Model 3B+ and a Model 400, both running Buster. Is there any software that I could use to make this work?
1 Answer
This is very straight forward; I have a Pi4 wired to my desktop this way. The most significant issue would be whatever networking daemon(s) you have running getting in the middle of things. If you are using the RpiOS default dhcpcd
, add to /etc/dhcpcd.conf
on both Pi's:
denyinterfaces eth0
This just tells it to not do anything with this.
You need to decide on a private address range to use. Something in 10.x.x.x
is normal here since it is big enough to prevent conflicts, and most inet routers use 192.168.x.x
anyway. The CIDR suffix can be /30
, since two bits can have four different values and you only need two (pretty sure you could use /31
and having one as 10.x.x.0
in this context, but that is not a good practice).
On one Pi:1
sudo ip link set eth0 up
sudo ip addr add 10.100.0.1/30 dev eth0
On the other:
sudo ip link set eth0 up
sudo ip addr add 10.100.0.2/30 dev eth0
Hopefully the difference is clear. The kernel should automagically set a route when this is done -- check with ip route
, the output should include:
10.100.0.0/30 dev eth0 proto kernel scope link src 10.100.0.1
The last address should be that of the Pi. If you don't see this route, you can add it manually:
sudo ip route add 10.100.0.0/30 via 10.100.0.1 dev eth0
Again, that last via
address should be that of the local Pi, not the other one. You should now be able to ping back and forth and do anything else IP networking wise.
- If you didn't boot up with that
denyinterfaces
set, you should restartdhcpd
(systemctl restart dhcpcd
), check if there is an a non link local address set already (ip a
), and remove that if necessary first (sudo ip addr del x.x.x.x dev eth0
), but I don't think there will be. A "link local" address begins169.254.x.x
, don't worry about that.