18 April 2010

Linux route add command


Q. How do I add new / default gateway using route command under Linux?
A. You can use any one of the following tool to add route:
=> route command : show / manipulate the IP routing table
=> ip command : show / manipulate routing, devices, policy routing and tunnels

Linux route add using route command

Route all traffic via 192.168.1.254 gateway connected via eth0 network interface:
# route add default gw 192.168.1.254 eth0

Linux route add using ip command

Just like above but with ip command:
# ip route add 192.168.1.0/24 dev eth0

Restart Networking

/etc/init.d/networking {stop|start|restart}

No comments:

Post a Comment