Skip to contentSkip to conversation

route trouble with kernel

DISCUSSION cigarette Chan 3 participants 4 messages Jun 28, 2005 – Jun 29, 2005

lore
Share & tools
lore
#0 lore raw

i add a route to the kernel
eg: # route add -net XXX.XXX.XXX.XXX/24 gw XXX.XXX.XXX.XXX dev eth1

but after i restart eth1

#ifdown eth1
#ifup eth1

the route disappear,this make me a lot of troubles.i have several interfaces,and i have to
re-add all of these routes...

Is there any way or patches to make route work like iptables,after i restart the interface,
rules are still there.

#1 lore raw

It could be argued that if iptables retains its parameters after its only interface has been shut down it's a bug.

The fact that no routes remain after a network interface has been shut down is both logical and in conformance with de facto Unix standards. This is partially as a result of route's manipulating flags (the UP flag would be wrong if the interface was down).

I can't imagine that you have so many routes that it takes a significant amount of time to reset them using a script. If so, you probably have a configuration error where you are not properly using netmasks. Certainly, you shouldn't have to establish a host-route for every host on your network. You only need a network route (out the interface) and a default route that goes to some router to get out of your LAN. Even if you __are__ a router, the network setup remains about the same, only the user-mode software changes, which may dynamically alter the routing tables.

Quoted 8 lines · cigarette Chan

i add a route to the kernel
eg: # route add -net XXX.XXX.XXX.XXX/24 gw XXX.XXX.XXX.XXX dev eth1

but after i restart eth1

#ifdown eth1
#ifup eth1

Quoted 7 lines

the route disappear,this make me a lot of troubles.i have several interfaces,and i have to
re-add all of these routes...

Is there any way or patches to make route work like iptables,after i restart the interface,
rules are still there.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.12 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.

#3 lore raw
In reply to cigarette Chan
Quoted 8 lines · cigarette Chan

i add a route to the kernel
eg: # route add -net XXX.XXX.XXX.XXX/24 gw XXX.XXX.XXX.XXX dev eth1

but after i restart eth1

#ifdown eth1
#ifup eth1

Quoted 7 lines

the route disappear,this make me a lot of troubles.i have several interfaces,and i have to
re-add all of these routes...

Is there any way or patches to make route work like iptables,after i restart the interface,
rules are still there.

Your system should have a way of doing this in a callout during the ifup and ifdown scripts. Under Fedora, ifup calls ifup-post, which calls /sbin/ifup-local - you could add your routes there.

More importantly, routes are different from iptables. At worst, an iptable rule has a dangling '-i ethX' match that will fail if the interface is down, but that's a harmless because the packet isn't from that interface.

On the other hand, what is the kernel supposed to do with a route that points to a down'ed ethX after you've done the ifdown, but before you've done the ifup? It may as well clear routes to the down'ed interface....

author
#2 lore raw
In reply to Richard B. Johnson
Quoted 45 lines · Richard B. Johnson

It could be argued that if iptables retains its parameters after its only interface has been shut down it's a bug.

The fact that no routes remain after a network interface has been shut down is both logical and in conformance with de facto Unix standards. This is partially as a result of route's manipulating flags (the UP flag would be wrong if the interface was down).

I can't imagine that you have so many routes that it takes a significant amount of time to reset them using a script. If so, you probably have a configuration error where you are
not properly using netmasks. Certainly, you shouldn't have to establish a host-route for every host on your network. You only need a network route (out the interface) and a default route that goes to some router to get out of your LAN. Even if you __are__ a router, the network setup remains about the same, only the user-mode software changes, which may dynamically alter the routing tables.

Quoted 8 lines · cigarette Chan

i add a route to the kernel
eg: # route add -net XXX.XXX.XXX.XXX/24 gw XXX.XXX.XXX.XXX dev eth1

but after i restart eth1

#ifdown eth1
#ifup eth1

Quoted 7 lines

the route disappear,this make me a lot of troubles.i have several interfaces,and i have to
re-add all of these routes...

Is there any way or patches to make route work like iptables,after i restart the interface,
rules are still there.

Quoted 6 lines

Cheers,
Dick Johnson
Penguin : Linux version 2.6.12 on an i686 machine (5537.79 BogoMips). Notice : All mail here is now cached for review by Dictator Bush. 98.36% of all statistics are fiction.

my host is a vpn gateway, and i have several virtual interface to run vpn. ie tap0, tap1....
I have to add routes to these TAPs to make vpn work. but after i restart the tapX, i have
to re-add routes relate to this interface~

If i have to maintain several vpn and lots of TAPs , So i need a simple way to maintian route tables.
sometimes it's quite diffcult to do this with shell scipts ,especially when it's quite complex.

thanks~