Static route in Linux

To add route in linux we can use the following command:

route add -net netmask gw dev eth0

The above command will add a route in the routing table. We can check by the command:

route -n

The disadvantage of the command that as soon as the system reboots the route is removed you have to run the command again.To add route such that it stay even after the reboot we can edit one file and that will keep the route in the routing table even after the reboot.

Inside directory


there is a file named as interfaces we can add the following line into it:

post-up route add -net netmask gw

If you try adding the following line it might not work.

route add -net netmask gw

Above command have been tested in Kali Linux 1.0

This entry was posted in Linux. Bookmark the permalink.