Wednesday, July 14, 2010

CentOS static routes

Temporary Static Route
Use the route command to add a static route.
route add -host 192.168.1.2 gw 192.168.50.254 dev eth0:0 (eth0:0 is virtual interface)

Permanent Static Route
echo "192.168.1.2/32 via 192.168.50.254" >> /etc/sysconfig/network-scripts/eth0:0

In both the cases above all requests to 192.168.1.2 will be routed via gateway 192.168.50.254 and device eth0:0