0

Every time I restart the server or "systemctl restart network" I have to add the static routes

Rhel 7.8

ip route add 192.168.1.1 dev ens192 proto static scope link metric 100
ip route add 192.168.2.0/24 dev ens192 proto kernel scope link src 192.168.2.11 metric 100
ip route add default via 192.168.1.1 dev ens192 proto static metric 100

Below is what get added:

# ip route
169.254.0.0/16 dev ens192 scope link metric 1002
172.16.2.0/24 dev ens192 proto kernel scope link src 172.16.2.11

How do I make the route static

# ip route
default via 172.16.1.1 dev ens192 proto static metric 100
172.16.1.1 dev ens192 proto static scope link metric 100
172.16.2.0/24 dev ens192 proto kernel scope link src 172.16.2.11 metric 100
Anthony Fornito
  • 9,546
  • 1
  • 34
  • 124

1 Answers1

1

Adding IP Routes via commandline is only temporary, to add the routes permanently, you must add them to the per-interface files in /etc/sysconfig/network-scripts/.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-configuring_static_routes_in_ifcfg_files

Davidw
  • 1,222
  • 3
  • 14
  • 25