I am using ip route to set up routing tables for a network. Everything is working great, but after a short amount of time (minutes) I lose some of my connections. When I look at my ip route, my changes are missing. They also drop if I lose connection to another network or reboot the computer.


I am working with a several Raspberry Pi Zero (RPiZ 1,2,3,4) plugged into a single Raspberry Pi 4 (RPi4 A) plugged into a switch. Another RPi4 B is also plugged into the router.

RPi4 A is connected to

  • switch via eth0 at
  • RPiZ1 via usb1 at
  • RPiZ2 via usb1 at
  • RPiZ3 via usb1 at
  • RPiZ4 via usb1 at

RPiZ1 is connected to RPi4A via usb0 at

RPiZ2 is connected to RPi4A via usb0 at

RPiZ3 is connected to RPi4A via usb0 at

RPiZ4 is connected to RPi4A via usb0 at

RPi4B is connected to switch via eth0 at

The goal is connect RPi4B with all 4 RPiZ.

RPi4B routes packets through RPi4A

ip route add via dev eth0
ip route add via dev eth0
ip route add via dev eth0
ip route add via dev eth0

Each RPiZ routes packets via RPi4A

ip route add via dev usb0
ip route add via dev usb0
ip route add via dev usb0
ip route add via dev usb0

RPi4A has IP forwarding turned on and routes packets appropriately.

ip route add dev usb1
ip route add dev usb2
ip route add dev usb3
ip route add dev usb4
ip route add dev eth0

Also, all of them are able to connect to my phone's hot spot via wlan0 at, and internet traffic goes there by default, though I am not sure that is set up totally right. I usually do not touch it. Occasionally I have to delete eth0 as the default for the RPi4 to get that to work.

All of that works great, for a little while, and then it breaks suddenly. When I get back connected I find that my added rules are missing especially the rules on the RPiZ. Some times, it seems like no reason. I know that if I disconnect or connect my hotspot, the rules will break or disappear. They also disappear on reboot.

Can anyone help my to make these permanent for network changes, reboots, and odd losses? The network is supposed to operate with intermittent WiFi and power in a remote location, so I need to make it robust.

Thanks in advance! Russ

1 Answer 1


Concerning the reboot, you need to add the route as persistent. When you execute the command in a terminal it will disappear on the next startup or it something happen to interface . Here a link to configure route as persistent. Can you first try to configure it then execute this command sudo service dhcpcd restart or do a reboot to check the configuration if it's working

  • Welcome to the site, and thank you for your contribution. Please note however that in its current form your post looks like troubleshooting advice rather than a definitive answer. If that was not intended, please edit the post to make the explanation clearer. Otherwise, it might be best placed as a comment under the original question.
    – AdminBee
    Commented Jan 11, 2022 at 11:12
  • That seems to have worked, but I made a mistake and added a line to each ip route replace default dev wlan0. That line is bad, so I deleted, but the entry keeps coming back, so I need to run ip route del default every few minutes. Any idea how to get rid of one?
    – Rusty
    Commented Jan 13, 2022 at 20:50
  • So I use emacs for my text editing. While editing, emacs makes a back up file called 40-route~. DHCPCD doesn't know this is a back up file so it runs it as a hook as overwrites my new rules with my old rules.
    – Rusty
    Commented Jan 15, 2022 at 18:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .