Static Routes
From Leo's Notes
This page was last edited on 1 September 2019, at 03:54.
How to set static routes on Linux and Windows.
Linux
Temporary Route
# ip route add 136.159.9.1 dev eth1
# ip route add 10.0.0.0/8 via 136.159.9.1
This will be wiped if the network gets restarted or if the machine reboots.
Persistent Routes (RedHat Based)
To make your route survive a reboot, ensure that there is a gateway set in /etc/sysconfig/network-scripts/ifcfg-eth1. Eg:
DEVICE="eth1"
BOOTPROTO="static"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=136.159.9.9
GATEWAY=136.159.9.1
NETMASK=255.255.255.0
Then, define the static routes in /etc/sysconfig/network-scripts/route-eth1:
default 136.159.9.1 dev eth1
10.0.0.0/8 via 136.159.9.1 dev eth1
Windows
Use the route command.
Temporary
To make 9.11.9.11 route to 10.1.2.2:
C:>route add 9.11.9.11 mask 255.255.255.255 10.1.2.2
OK!
This route will be lost on a reboot.
Persistent
To make a rule persistent, just add -p to the route command.
Eg:
C:>route -p add 9.11.9.11 mask 255.255.255.255 10.1.2.2
OK!