LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-19-2005, 09:58 AM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
automatic static routes?


Is there a way I can automatically add static routes once a network interface goes up?

Last edited by eantoranz; 07-19-2005 at 10:05 AM.
 
Old 07-19-2005, 05:05 PM   #2
cjcox
Member
 
Registered: Jun 2004
Posts: 307

Rep: Reputation: 42
This will vary from distribution to distribution. Worst case, you can always find the init script that starts your network and hardcode your static routes (route add .. etc.) onto it.

What distribution are you using?
 
Old 07-19-2005, 07:08 PM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Oh... I know where to write stuff for the boot process..... but I mean if during normal operation, one link is brought down and back up.

(It's Ubuntu).
 
Old 07-19-2005, 08:11 PM   #4
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
I've never actually used ubuntu but since it's debian based I'm gonna assume it's the same as in debian proper. Put a line for each static route in /etc/network/interfaces. Eg let's say eth1 is connected through gateway 192.168.1.254 to the 10.0.0.1/24 network:

Code:
iface eth1 inet static
        up route add -net 10.0.0.1/24 gw 192.168.1.254
        down route del -net 10.0.0.1/24 gw 192.168.1.254
        address 192.168.1.1
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
This will call the command on the line starting with up (sans the up itself) whenever the interface goes active.
 
Old 07-19-2005, 08:17 PM   #5
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
But that will work if I use the /etc/init.d/networking script, right?

How about if I use ifconfig eth0 down; ifconfig eth0 up? will it work anyway?
 
Old 07-19-2005, 08:30 PM   #6
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
It works with /etc/init.d/networking and ifup/ifdown since these scripts read the interfaces file. It will not work when you use ifconfig.
 
  


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
static routes using route-eth0 file sti2envy Linux - Networking 2 09-08-2007 09:10 AM
How do I config static routes? mikezang Linux - Networking 4 10-31-2005 10:29 AM
Max Static Routes? roundst Linux - Networking 2 07-28-2005 02:51 AM
Setting static routes on LAN cranium2004 Linux - Networking 3 01-06-2005 11:57 PM
static-routes in Mandrake 10.0 tallthom Mandriva 1 09-27-2004 12:51 AM

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

All times are GMT -5. The time now is 11:38 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