How to Add Linux route ?

You can use any one of the following tool to add, display, delete Linux kernel routing table:

(a) route command : show / manipulate the IP routing table on Linux.

(b) ip command : show / manipulate routing, devices, policy routing and tunnels on Linux.

Display your current routing table

Open the Terminal or login to server using ssh/console. Type the  following command to display routing table:

# route
# route -n


 # ip route show
 # ip route list

Linux add a default route using route  command

Route all traffic via gateway connected via eth0 network interface:

 # route add default gw eth0

Linux add a default gateway (route) using ip command

Route all traffic via gateway connected via eth0 network interface:

 # ip route add dev eth0

Verify newly added route ip in the Linux kernel routing table

To verify new routing table, enter:
 # ip route list
 # route -n

How do I make routing changes persistent across reboots?

To make route entry persistent in the Linux kernel routing table, you need to modify config file as per your Linux distributions.

RHEL/CentOS/Fedora/Scientific Linux persistent routing configuration

Edit /etc/sysconfig/network and set default gateway IP address:
# vi /etc/sysconfig/network
Sample outputs:


You can add additional static route for eth0 by editing /etc/sysconfig/network-scripts/route-eth0 file as follows: via

The above config sets static routing for network via router.

Debian / Ubuntu Linux persistence static routing configuration

Edit /etc/network/interfaces file, enter:
# vi /etc/network/interfaces
Append the following in eth0 section:

up route add -net netmask gw
down route del -net netmask gw

Save and close the file.

Generic method to add persistent static routing on Linux

The following method works with almost all Linux distributions.

Edit /etc/rc.d/rc.local or /etc/rc.local, enter
# vi /etc/rc.local
Append the following line:

/sbin/ip route add dev eth0

Save and close the file.

Leave a Reply

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

CAPTCHA * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.