LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-24-2004, 09:06 AM   #1
WeNdeL
Member
 
Registered: Oct 2002
Location: At my desk...
Distribution: RedHat, Fedora, Ubuntu
Posts: 344

Rep: Reputation: 30
Network restart and additional routes


I have two routes that are added to my routing table upon boot. I have commands in rc.local that add these routes.

When I restart networking on this machine, these routes dissappear. Duh right?

Where can I put them such that they will reappear when I restart networking on my machine?

I am using a RH machine...
 
Old 05-24-2004, 11:27 AM   #2
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,534

Rep: Reputation: 100Reputation: 100
Put'em in the networking script. On Slack, they're called rc.inet1 and rc.inet2.
 
Old 05-24-2004, 12:30 PM   #3
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
u can use /etc/sysconfig/static-routes file in redhat. (from /etc/rc.d/init.d/network file)
but adding static routes in this file a tille defference.

if u want to add a route u type in terminal like this:
#route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.0.1

but if u wanna add same touting by using this file, use the following syntax
any net 192.168.20.0 netmask 255.255.255.0 gw 192.168.0.1

it will read the static routes file when u restart network.
 
Old 05-24-2004, 08:50 PM   #4
WeNdeL
Member
 
Registered: Oct 2002
Location: At my desk...
Distribution: RedHat, Fedora, Ubuntu
Posts: 344

Original Poster
Rep: Reputation: 30
awesome, thanks guys!
 
Old 05-24-2004, 10:22 PM   #5
mlp68
Member
 
Registered: Jun 2002
Location: NY
Distribution: Gentoo,RH
Posts: 333

Rep: Reputation: 40
All true, and it'll work, but it's not the whole story. The above method helps only if you shut down and restart the whole network, which you may not do (maybe you just shut down one interface by, say, "ifdown eth0" without going through the network script). You want to selectively set up and take down the routes that are specific to an interface.

The generic way, which is admittedly a bit obscure, is to have a file
/etc/sysconfig/networking/devices/<interfacename>.route
e.g.
/etc/sysconfig/networking/devices/eth0.route

with the contents

ADDRESS0=xx.xx.xx.xx
NETMASK0=255.255.xxx.yyy
GATEWAY0=192.168.30.24

and ADDRESS1/NETMASK1/GATWAY1 for the next route, and so on

For example
ADDRESS0=192.168.7.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.30.24

will add a route to the 192.168.7 network through 192.168.30.24.

The nice thing that this is network-device dependent, so the routes aren't brought on unconditionally but only when the interface actually goes up, and does not depend on a particular method.

Hope it helps,
mlp
 
Old 05-25-2004, 04:59 AM   #6
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
thnx mlp68
your suggest is better than mine.
 
  


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
Network not accessible after boot; OK after network restart chriswei Linux - Networking 5 09-22-2004 10:16 PM
restart network JROCK1980 Linux - Networking 7 05-11-2004 07:23 AM
Network Restart vofkid Linux - Newbie 1 03-14-2002 12:08 PM
Adding Additional Network Cards CRF Linux - Networking 4 06-05-2001 01:52 AM
Adding additional Network to VPN Shoki Linux - Networking 0 05-24-2001 01:53 PM

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

All times are GMT -5. The time now is 05:34 AM.

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