How to add static routes in ubuntu

How to add static routes in Ubuntu

Static routing is the way to route the internet traffic manually.it does not required any network protocol to set it up,but be aware of network changes to reconfigure static routes.
Command :

route add (-net/-host) <IP/Netword address> netmask <subnetmask> gw <Gateway> dev <Interface>

Example :

route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0route add -host 192.168.10.10 netmask 255.255.255.0 gw 192.168.1.1 dev eth0

To view network configurations :

# ifconfig                                           or

# nano /etc/network/interfaces 

if the configurations are not saved then

sudo /etc/init.d/networking restart 

and check again ,

Leave a Reply

Your email address will not be published. Required fields are marked *