Setting static route in Debian-Linux

Simple network routes can be set under Linux using the route command become. Here is a simple example:

route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.0.1

In order for this change to be active even after a restart, the file /etc/network/interfaces must be changed.

iface ens192 inet static
address 192.168.0.156/24
up /bin/ip route add 10.25.20.0/24 via 192.168.0.1

Leave a Comment