A
A
aphazel2019-01-14 18:30:47
linux
aphazel, 2019-01-14 18:30:47

How to set static routes on Debian 9.6 so they don't get reset after reboot?

There is Debian 9.6 and configured in it /etc/network/interfaces:

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens192
auto ens192
iface ens192 inet static
        address 192.168.72.152
        netmask 255.255.255.0
        gateway 192.168.72.1
post-up route add -net 192.168.24.0 netmask 255.255.254.0 gw 192.168.72.101
pre-down route del -net 192.168.24.0 netmask 255.255.254.0 gw 192.168.72.101

The trouble is that after a reboot, the routes are reset. Previously, they could be entered into the config and they worked after a reboot, but now it works in a way that is incomprehensible to me. What to do and why the method does not work? Manually adding routes works, but I don't want to do this after a reboot.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Softer, 2019-01-14
@aphazel

post-up route add -net 192.168.24.0 netmask 255.255.254.0 gw 192.168.72.101
pre-down route del -net 192.168.24.0 netmask 255.255.254.0 gw 192.168.72.101

>>>>
post-up /sbin/ip r add 192.168.24.0/23 via 192.168.72.101
pre-down /sbin/ip r del 192.168.24.0/23 via 192.168.72.101

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question