How to add static route on CentOS 7 and RHEL 7

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:-

[root@urclouds ~]# ip route show
default via 192.168.43.1 dev enp0s3
169.254.0.0/16 dev enp0s3  scope link  metric 1002
192.168.43.0/24 dev enp0s3  proto kernel  scope link  src 192.168.43.15
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1
[root@urclouds ~]#

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

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 10.10.20.0/24 via 192.168.43.15 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:-

[root@urclouds network-scripts]# cat route-enp0s3
10.10.20.0/24 via 192.168.43.15 dev enp0s3
[root@urclouds network-scripts]#

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

[root@urclouds ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[root@urclouds ~]#

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

[root@urclouds ~]# ip route show
default via 192.168.43.1 dev enp0s3
10.10.20.0/24 via 192.168.43.15 dev enp0s3
169.254.0.0/16 dev enp0s3  scope link  metric 1002
192.168.43.0/24 dev enp0s3  proto kernel  scope link  src 192.168.43.15
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1
[root@urclouds ~]#

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.

This Post Has 36 Comments

  1. short term loans no credit check no brokers

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

  2. oprolevorter

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

  3. Crave Freebies

    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!

  4. Karl

    Very rapidly this website will be famous amid all blogging and site-building visitors, due to it’s nice content

  5. watch

    This blog was… how do I say it? Relevant!! Finally I have found something that helped me. Appreciate it!

  6. card game baccarat - 918indo.com

    I loved this post! I read your blog fairly often and you
    are always coming out with some great stuff. I will shares this on my facebook, instagram and some of my loyalty followers.
    Great jobs! Keep work it with it.

  7. Rosendo Aures

    I just want to say I am beginner to blogging and absolutely loved you’re web page. Probably I’m going to bookmark your website . You actually come with excellent articles and reviews. Thanks a bunch for revealing your blog.

  8. Wilbur

    Thanks very nice blog!

  9. Marisol

    I’m really impressed with your writing skills as well as with the layout on your blog.
    Is this a paid theme or did you modify it yourself?
    Either way keep up the nice quality writing,
    it’s rare to see a great blog like this one these days.

  10. Rolf Doing

    Hello There. I found your blog the use of msn. That is an extremely smartly written article. I’ll be sure to bookmark it and come back to learn extra of your useful information. Thank you for the post. I will certainly return.|

  11. Jenice Feris

    Hi, just wanted to mention, I liked this post. It was funny. Keep on posting!|

  12. Yolonda Paniccia

    I do consider all of the ideas you have presented in your post. They are very convincing and will definitely work. Still, the posts are very short for novices. May just you please lengthen them a little from next time? Thank you for the post.|

  13. Yong Timlin

    Hello friends, fastidious piece of writing and good urging commented here, I am in fact enjoying by these.|

  14. James Kendziora

    Fantastic goods from you, man. I’ve consider your stuff previous to and you are just extremely magnificent. I really like what you’ve obtained right here, really like what you’re saying and the way in which by which you say it. You are making it entertaining and you continue to care for to stay it wise. I can’t wait to read far more from you. This is actually a terrific site.|

  15. Sherwood Stillson

    You really make it appear so easy with your presentation however I in finding this topic to be actually one thing which I think I would never understand. It sort of feels too complex and extremely broad for me. I’m taking a look ahead for your subsequent submit, I will try to get the cling of it!|

  16. Demetrice Alegria

    Hi there, I found your blog by means of Google even as searching for a related topic, your web site got here up, it looks good. I have bookmarked it in my google bookmarks.

  17. Lewis Fattig

    Hello to all, how is all, I think every one is getting more from this web site, and your views are good designed for new users.|

  18. Felix Mcweeney

    Thank you for some other magnificent post. The place else may just anybody get that type of information in such an ideal way of writing? I have a presentation next week, and I am on the search for such info.|

  19. casino online

    Hey, thanks for the post. Really Great.

  20. katalog firm

    Wow! This blog looks just like my old one! It’s
    on a completely different topic but it has pretty much the same
    layout and design. Superb choice of colors!

  21. Federico Pignatello

    It is not my first time to visit this web page, i am browsing this website dailly and get pleasant facts from here everyday.|

  22. Malik Hinckle

    After I initially commented I seem to have clicked on the -Notify me when new comments are added- checkbox and from now on each time a comment is added I receive 4 emails with the exact same comment. There has to be a means you are able to remove me from that service? Thank you!|

  23. auto approve list

    Hi there, of course this post is truly good and I have learned lot of things from it concerning blogging.
    thanks.

  24. Sonny Rocha

    Hi to every one, the contents existing at this website are truly awesome for people experience, well, keep up the good work fellows.|

  25. Erline Ellingwood

    We stumbled over here different website and thought I might check things out. I like what I see so now i’m following you. Look forward to exploring your web page again.|

  26. Rana Edland

    What’s up, constantly i used to check website posts here early in the break of day, for the reason that i enjoy to learn more and more.|

  27. Jane Bohlsen

    Very soon this web site will be famous amid all blog people, due to it’s pleasant posts|

  28. Meda Mezera

    Thanks on your marvelous posting! I really enjoyed reading it, you may be a great author. I will be sure to bookmark your blog and may come back at some point. I want to encourage you to definitely continue your great work, have a nice morning!|

  29. roulette

    This article offers clear idea in favor of the new people of blogging, that truly how
    to do blogging and site-building.

  30. Kami Lowthorp

    We are a gaggle of volunteers and starting a brand new scheme in our community. Your web site provided us with valuable info to work on. You’ve done an impressive job and our entire community will be grateful to you.|

  31. Jenee Thakkar

    I really like your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you? Plz reply as I’m looking to create my own blog and would like to find out where u got this from. thanks|

  32. DennisWhode

    It as not that I want to duplicate your web site, but I really like the design. Could you tell me which style are you using? Or was it custom made?

  33. real online casino

    My brother recommended I might like this blog.
    He was totally right. This post truly made my day. You cann’t imagine just how much time I had spent for this information! Thanks!

  34. Velda Ferraro

    What’s up, always i used to check web site posts here in the early hours in the break of day, because i like to gain knowledge of more and more.|

  35. Oliver Guarnera

    I’d should examine with you here. Which isn’t something I normally do! I take pleasure in reading a submit that may make folks think. Also, thanks for permitting me to remark!

Leave a Reply