How to add static route on CentOS 7 and RHEL 7

Last updated on October 8, 2019

In this tutorial, we will see how to add static route on CentOS 7 and RHEL 7. We will also know what is static route? And why we need to add static route? So first of all we should know what is static route?

What is static route?

Static routing is a form of routing that occurs when a router uses a manually-configured routing entry, rather than information from a dynamic routing traffic. Network administrator can manually configured static routes by adding in entries into a routing table.

Static routes are fixed and do not change if the network is changed or reconfigured. Static routing and dynamic routing are not mutually exclusive.

Dynamic routing and static routing are usually used on a router to maximize routing efficiency and to provide backups in the event that dynamic routing information fails to be exchanged.

For more details about static route you can Click Here

Why we use static route?

  1. Static routing can be used to define an exit point from a router when there is no any other routes are available or necessary. This is called a default route.
  2. Static routing can be used for small networks which require only one or two routes.
  3. Static routing is often used as a complement to dynamic routing to provide a failsafe backup in the event that a dynamic route is unavailable.

Now let’s start static route configuration. We can check our IP table with below commands like below:-

[[email protected] ~]# ip route show
default via dev enp0s3 dev enp0s3  scope link  metric 1002 dev enp0s3  proto kernel  scope link  src dev virbr0  proto kernel  scope link  src
[[email protected] ~]#

In the above screen shot you can see that any packets to reach a destination network ID should travel via enp0s3 interface with and any other destination network not implicitly defined should use a default gateway

Now I am going to add one static route where we can define Network as well as specify via which IP address and interface the packet should travel through in order to reach its destination.

For example, let’s add a static route to destination network via ip address and enp0s3 interface.

To do this we need to create a new file route-enp0s3 in a /etc/sysconfig/network-scripts/ directory.

We can define an above mentioned persistent static route add a following line into our route-enp0s3 file. Like below:-

[[email protected] network-scripts]# cat route-enp0s3 via dev enp0s3
[[email protected] network-scripts]#

After entry into the file we need to restart network service. Like below:-

[[email protected] ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[[email protected] ~]#

we need to check our new static route has been correctly defined or not.

[[email protected] ~]# ip route show
default via dev enp0s3 via dev enp0s3 dev enp0s3  scope link  metric 1002 dev enp0s3  proto kernel  scope link  src dev virbr0  proto kernel  scope link  src
[[email protected] ~]#

That’s all you can see we have successfully added one static route on CentOS 7.

You can also see Network configuration after CentOS 7 minimal installation.

Ifconfig command not found in CentOS 7 and RHEL 7


  1. short term loans no credit check no brokers said:

    I like this, but I do have a question. Do you mind answering?

    May 29, 2019
  2. oprolevorter said:

    You made some clear points there. I looked on the internet for the topic and found most persons will approve with your blog.

    July 1, 2019
  3. Crave Freebies said:

    Someone essentially help to make severely articles I’d state. That is the very first time I frequented your web page and to this point? I amazed with the research you made to create this actual put up amazing. Excellent activity!

    August 1, 2019

Leave a Reply

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