HowTo : Permanently Add Static Route In Linux

static route linux permanent

add static route

Static routing is the process of manually entering the routes to the routing table to reach a particular destination. So, the data from one point to another uses the same path regardless of other considerations. The main advantages of static routes are its control, predictability and improved performance. In this article we will learn how to add permanent static routes in Linux (redhat) machine.

Temporarily adding static routes

In order to add a static route temporarily on your Linux machine, you can use route command. The newly added route will be available till next reboot. You can list the current routing table as follows.

# route –n

If you want to add a route to the network through the gateway, you can execute the following command.

# route add -net netmask gw198.161.1.10dev eth0

Adding Permanent Static routes

In order to add permanent static routes, you need to modify the interface file in /etc/sysconfig/network-scripts. For example, here, we have to add routes on eth0. Hence, the file we need to modify will be,/etc/sysconfig/network-scripts/route-eth0.

The basic syntax of static route in this file is

Target_address via gateway_address

So, in order to add the above route in route-eth0 file, append the following line. via

Then, you need to restart network service.

# service network restart

Finally verify that the new routes are visible in routing table using the following command.

# route -n

Bobbin Zachariah 11:25 pm

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

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

All comments are subject to moderation.