Adding permanent static route

metaphase

New Member
Nov 24, 2024
8
3
3
Background: running PVE 8.4.1, have an offsite PBS (IP 192.168.2.150) that I want to send backups to, running Tailscale LXC (IP 192.168.1.200) with subnet routing enabled.

If I manually add a static route with ip route add 192.168.2.150 via 192.168.1.200 dev vmbr0 then I can ping the PBS fine and have successfully added it in PVE as a storage location and run a backup job.

I therefore wanted to add it as a permanent route. Although I guess I could run the above command using an @reboot command in crontab my understanding was that the correct way to do it was by adding a route /etc/network/interfaces, however no matter what I do I can't seem to get it to work; after reboot (when my temporary static route has disappeared) it doesn't show up in ip route list and I can't ping the PBS.

My full /etc/network/interfaces file is:
Bash:
auto vmbr0
iface vmbr0 inet static
        address 192.168.1.100/24
        gateway 192.168.1.1
        bridge-ports enp4s0
        bridge-stp off
        bridge-fd 0
        post-up route add 192.168.2.150/32 via 192.168.1.200

I've tried some variations on this syntax, including just up rather than post-up, using route add -net, specifying a netmask rather than CIDR and using gateway rather than via (e.g., post-up route add -net 192.168.2.150 netmask 255.255.255.255 gw 192.168.1.200), but none of them seem to work.

ip route list:
Bash:
default via 192.168.1.1 dev vmbr0 proto kernel onlink
192.168.1.0/24 dev vmbr0 proto kernel scope link src 192.168.1.100

Thanks in advance for any suggestions.
 
Last edited:
Apologies, excellent point - the actual ones I'm using are <255 I was just trying to use round numbers for the illustration rather than the slightly random ones in my setup! I'll update my code above to reflect that but they were definitely within the valid range.
 
Ahh fantastic - thank you! I searched quite a few resources and kept finding different options but not that one! Interestingly running a systemctl restart networking didn't seem to work afterwards (I'd been led to believe it should) but after a full reboot of PVE it's showing up correctly in the route list and working nicely - many thanks @MarkusKo ! :):cool:
 
Last edited:
  • Like
Reactions: waltar