[SOLVED] Adding permanent route to vmbr4

Gamienator

Member
Mar 16, 2021
43
6
13
33
Hello everyone,

I have a really dumb question but can't find any solution. How can I add a permanent route in ProxmoxVE?

I got a bridge `vmbr4` which should get a static route

ip route add 192.168.178.0/24 via 172.30.0.1

But the typical solution to add this in /etc/network/interfaces can't be done, since it will be overwritten. Does anybody got a different Idea on how to add this?

Thanks!

Cheers,
Gamie
 
  • Like
Reactions: utkonos
Hello everyone,

I have a really dumb question but can't find any solution. How can I add a permanent route in ProxmoxVE?

I got a bridge `vmbr4` which should get a static route

ip route add 192.168.178.0/24 via 172.30.0.1

But the typical solution to add this in /etc/network/interfaces can't be done, since it will be overwritten. Does anybody got a different Idea on how to add this?

Thanks!

Cheers,
Gamie
maybe this can help ?

https://forum.proxmox.com/threads/route-add-problem.94345/
 
  • Like
Reactions: utkonos
But won't that be overwritten on the next reboot / Update of the network interfaces? Since the GUI writes then the config? Since there is written DO NOT MODIFY" :)

Route IP Traffic​

Routes are dynamically managed using the route or ip route commands.

A default routes can be managed as follows.

# route del default gw 192.168.0.1
# route add default gw 192.168.0.1

# ip route del default via 192.168.0.1
# ip route add default via 192.168.0.1
Specific routes can be added, with or without a default gateway setting, using the following commands.

# route add -net 172.168.2.0 netmask 255.255.255.0 dev eth0
# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth0

# ip route add 172.168.3.0/24 dev eth0
# ip route add 172.168.4.0/24 via 192.168.0.1 dev eth0
Route information is be displayed as follows.

# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
172.168.2.0 * 255.255.255.0 U 0 0 0 eth0
172.168.3.0 * 255.255.255.0 U 0 0 0 eth0
172.168.4.0 192.168.0.1 255.255.255.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
192.168.1.0 192.168.0.1 255.255.255.0 UG 0 0 0 eth0
#

# ip route
default via 192.168.0.1 dev eth0 proto static
169.254.0.0/16 dev eth0 scope link metric 1002
172.168.2.0/24 dev eth0 scope link
172.168.3.0/24 dev eth0 scope link
172.168.4.0/24 via 192.168.0.1 dev eth0
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.190
192.168.1.0/24 via 192.168.0.1 dev eth0
#
Routes are removed using the following commands.

# route del -net 172.168.2.0 netmask 255.255.255.0 dev eth0
# route del -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth0

# ip route del 172.168.4.0/24 via 192.168.0.1 dev eth0
# ip route del 172.168.3.0/24 dev eth0

Create Permanent Static Routes​

The static routes configured in the previous section are all transient, in that they are lost on reboot. To configure a permanent static route for an interface, create a file with the following format "/etc/sysconfig/network-scripts/route-<INTERFACE>". For example, we could create the "/etc/sysconfig/network-scripts/route-eth0" file with the following entries.

172.168.2.0/24 via 192.168.0.1 dev eth0
172.168.4.0/24 via 192.168.0.1 dev eth0
We can then stop and start the interface as follows.

# cd /etc/sysconfig/network-scripts/
# ifdown eth0
# ifup eth0
In addition, the default gateway can be specified globally in the "/etc/sysconfig/network" file, for the interface in the "/etc/sysconfig/network-scripts/ifcfg-<INTERFACE>".

the info above was from the link below:
maybe this might help you https://wiki.debian.org/NetworkConfiguration
 
Heyho, so I solved it in a different way, using a crontab :D

Bash:
@reboot /usr/sbin/ip route add 172.16.0.0/24 via 172.33.0.1
 
  • Like
Reactions: Spirog
But won't that be overwritten on the next reboot / Update of the network interfaces? Since the GUI writes then the config? Since there is written DO NOT MODIFY" :)

/etc/network/interfaces will be overwritten only in case you have pending changes (/etc/network/interfaces.new exists).
Otherwise you can modify /etc/network/interfaces as you wish. PVE GUI will parse your changes after you reload the web page.

up ip route command is ignored by GUI parser, so no need to use crontab for this.
 
  • Like
Reactions: soupdiver
It's supposed to be "up route add .. " when it's in the /etc/network/interfaces format, not "up ip route .. "
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!