LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-25-2009, 12:36 AM   #1
bala1987
LQ Newbie
 
Registered: May 2009
Posts: 2

Rep: Reputation: 0
Question Adding persistent static routes in Redhat.. [NISTnet installed...!]


Hi,

#1
How can i add static routes in RHEL.
Do i have to change "/etc/sysconfig/network-scripts/ifcfg-eth0" file i.e whether I have to add some routes towards the end of file.

And, what should be the format while adding the routes.

[when I add routes using 'route add -net', they disappear after I reboot the machine ]

#2
How can I make a script getting called automatically if the system reboots. eg. Assuming, I got a ScriptFile in "/root" which has to be called on system reload. I don't want to run it everytime by giving "./ScriptFIle" in terminal.
 
Old 05-25-2009, 10:13 AM   #2
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
kbase.redhat.com: using static routes

What is the correct syntax, using the 'ip' command, I can use to add or delete static routes from the system's IP routing table?

I am trying to configure static routes in Red Hat Enterprise Linux 3. Why do I keep getting an error that says 'Error: an inet prefix is expected rather than...' whenever I try and activate the static route?

It has been a few years since I last touched a RHEL3 installation and I no longer have one for reference...
In RHEL4 and RHEL5 (so i suspect it might be the same in RHEL3), one of the last items to get called from ifup-post is /sbin/ifup-local if it exists. It is a script that you'll create and takes a single argument (the interface; ex. eth0). Here is where you'll set the static routes that need to be added when the interface is activated. likewise, there is an /sbin/ifdown-local to handle things when the interface is deactivated.

an example /sbin/ifup-local:
Code:
#!/bin/bash
#
# my custom routing example for eth1 interface
#
if [ $1 = 'eth1']; then
   /sbin/ip route add 192.168.1.0/24 via 10.10.1.101 dev eth1
fi
#
#
 
Old 05-26-2009, 08:58 AM   #3
bala1987
LQ Newbie
 
Registered: May 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Hey, I found out the answer from red hat documentation..
Here's the answer.


Just create the file like this in /etc/sysconfig/network-scripts/

[root@localhost network-scripts]# cat route-eth0
50.1.0.0/16 via 50.44.0.1 dev eth0
50.2.0.0/16 via 50.44.0.1 dev eth0
200.30.0.0/16 via 50.44.0.1 dev eth0

And also add the routes for the other interface in the file route-eth1

[Actually I am using a 2 NIC linux machine..!!!]
 
  


Reply



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
Cannot add persistent routes janihemang Linux - Networking 2 08-05-2008 10:37 AM
Static routes using routes/ifroutes-eth-id.. files and default gateway disabled TimtheEagle Linux - Networking 0 05-31-2008 07:08 PM
persistent static routes, not so persistent Hewson Linux - Networking 4 04-27-2007 05:09 PM
Adding static routes to fc1 router Tom123 Linux - Networking 1 08-20-2004 03:28 AM
Question about persistent routes in redhat 9 shrike wensbot Linux - Networking 5 06-03-2003 08:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration