
▶ BLOG
KB No. 2003: ADDING A STATIC ROUTE
How to add a static route and make that route persistent.
Objective
Add a static route and make this route persistent.
STEPS
For example, use IP address 192.168.1.100 to reach network 192.168.2.0/24:
route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.100
Make this route available each time the eth0network interface is activated:
- For Debian-like (Debian, Ubuntu, etc.):
Write the following line in the /etc/network/interfaces file:
up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.100
- For CentOS, RedHat, etc.:
echo "192.168.2.0/24 via 192.168.1.100" >> /etc/sysconfig/network-scripts/route-eth0
For more information: www.akadia.com/services/redhat_static_routes.html.