How to add static route in Linux
Working with routes.
To view your current default route
# route -n
The result table would look like this
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
To add a route you must first know the network address of the network you wish to add, and the gateway to that network. Let us say we need to add the network of 10.0.0.0 with netmask 255.255.255.0 to be routed to 192.168.1.254 as its default gateway. here is how to do it:
# route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.1.254
This would add the network 10.0.0.0 with a netmask of 255.255.255.0 and a gateway routed to 192.168.1.254.
Basically that’s it.
You can also try an anternative route command
# ip route