LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-26-2012, 11:27 AM   #1
karim.wallani
LQ Newbie
 
Registered: Jun 2012
Posts: 8

Rep: Reputation: Disabled
CentOS 6 - Persistent Static Route


I am using CentOS 6. I have managed to add and delete static routes (using route add and route del commands, respectively), and now my routing table is the way I want it. It looks like this:

Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
111.68.222.48 0.0.0.0 255.255.255.240 U 0 0 0 eth1
10.1.8.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.0.0 10.1.8.1 255.0.0.0 UG 0 0 0 eth0
0.0.0.0 111.68.222.49 0.0.0.0 UG 0 0 0 eth1

What do I need to do to make this routing table persistent? I know it involves creating a file or two in /etc/sysconfig/network-scripts/, but which files do I need to create and what goes in each file?
 
Old 06-26-2012, 06:16 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,301

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
If you read /etc/sysconfig/network-scripts/ifup-routes, you'll see the naming convention
Code:
FILES="/etc/sysconfig/network-scripts/route-$1 /etc/sysconfig/network-scripts/route6-$1"
    FILES="$FILES /etc/sysconfig/network-scripts/route-$2 /etc/sysconfig/network-scripts/route6-$2"
Its not a long file; have a good read.
 
Old 06-26-2012, 10:54 PM   #3
karim.wallani
LQ Newbie
 
Registered: Jun 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
What I gather by reading /etc/sysconfig/network-scripts/ifup-routes is that I have to create the following two files:

1. /etc/sysconfig/network-scripts/route-eth0
2. /etc/sysconfig/network-scripts/route-eth1

So, if I want my routing table to look like this:

Destination Gateway Genmask Flags MSS Window irtt Iface
111.68.222.48 0.0.0.0 255.255.255.240 U 0 0 0 eth1
10.1.8.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.0.0 10.1.8.1 255.0.0.0 UG 0 0 0 eth0
0.0.0.0 111.68.222.49 0.0.0.0 UG 0 0 0 eth1

Then I should put the following in route-eth0:

ADDRESS0=10.1.8.0
GATEWAY0=0.0.0.0
NETMASK0=255.255.255.240
ADDRESS1=10.0.0.0
GATEWAY1=10.1.8.1
NETMASK1=255.0.0.0

And I should put the following in route-eth1:

ADDRESS0=111.68.222.48
GATEWAY0=0.0.0.0
NETMASK0=255.255.255.240
ADDRESS1=0.0.0.0
GATEWAY1=111.68.222.49
NETMASK1=0.0.0.0

Am I on the right track, or have I totally missed the mark???
 
Old 04-29-2013, 07:49 PM   #4
beowulfnode
Member
 
Registered: Jun 2007
Distribution: debian, ubuntu, centos, esxi
Posts: 39

Rep: Reputation: 4
It seems that the CentOS 5 documentation on static routes is applicable to CentOS 6
http://www.centos.org/docs/5/html/5....ic-routes.html

I don't know about CentOS 5 but on CentOS 6 you can just use lines like
10.2.7.0/24 via 10.1.0.7
10.5.0.0/16 via 10.1.0.8
to specify that traffic for
10.2.7.0 with netmask 255.255.255.0 goes via 10.1.0.7 and
10.5.0.0 with netmask 255.255.0.0 goes via 10.1.0.8
You seem to be able to skip putting on the last 2 parameters, such as "dev eth0" that are mentioned on the CentOS doc page.

I personally prefer this format as it seems neat in comparison to using multiple lines per route so if you have something like
10.1.0.0/16 via 10.2.0.4
10.3.0.0/16 via 10.2.0.4
10.4.0.0/16 via 10.2.0.4
10.5.0.0/16 via 10.2.0.4
10.6.0.0/16 via 10.2.0.4
10.7.0.0/16 via 10.2.0.4
10.8.0.0/16 via 10.2.0.4
10.9.0.0/16 via 10.2.0.4
10.10.0.0/16 via 10.2.0.4
it is very neat way to specify 9 static routes.

If you don't know how to convert between the CIDR and netmask notation have a read of these links
http://en.wikipedia.org/wiki/IPv4_subnetting_reference
http://en.wikipedia.org/wiki/Classle...Domain_Routing
 
Old 05-24-2013, 08:52 AM   #5
karim.wallani
LQ Newbie
 
Registered: Jun 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
I'm afraid this information does not really help me. I would request someone to please have a look at my comments again and see if they have some suggestions.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
persistent static route ANU Linux - Networking 5 04-01-2012 07:23 PM
route-eth - Adding a static route gbwien Linux - Networking 5 02-24-2012 05:15 AM
persistent static routes, not so persistent Hewson Linux - Networking 4 04-27-2007 05:09 PM
How does one make a static route persistent in AIX? artasse AIX 2 11-22-2006 02:51 PM


All times are GMT -5. The time now is 12:56 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration