multiple default routes bug/feature

David Monro (davidm@cs.su.oz.au)
Mon, 13 May 1996 22:44:14 +1000 (EST)


Hi,

running my pre2.0.2 diskless system (and 1.3.100 diskful machine) I seem to be
able to create multiple default routes with the same netmask and interface, but
different gateways:

(fuzzbox:129.78.97.193 is the server and router, elara is 129.78.97.194 and
metis is the diskless box at 129.78.97.196, net tools is 1.3.50-BETA6f)

Basic routes, no default route at all, and the odd ones installed on ifconfig
deleted:
elara:~ # netstat -rn
Kernel routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
129.78.97.192 0.0.0.0 255.255.255.248 U 0 0 18 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 3 lo

Add my standard default route:
elara:~ # route add -net default gw fuzzbox dev eth0
elara:~ # netstat -rn
Kernel routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
129.78.97.192 0.0.0.0 255.255.255.248 U 0 0 20 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 3 lo
0.0.0.0 129.78.97.193 0.0.0.0 UG 0 0 0 eth0

Add another bizzare route:
elara:~ # route add -net default dev eth0
elara:~ # netstat -rn
Kernel routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
129.78.97.192 0.0.0.0 255.255.255.248 U 0 0 22 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 3 lo
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 eth0
0.0.0.0 129.78.97.193 0.0.0.0 UG 0 0 0 eth0

Ummm...

Actually this is a slightly contrived example - on my diskless box, due to the
arguments passed in by the boot eprom (it passes in the gateway address as
0.0.0.0 which seems to confuse things) I get a routing table set up _by the
kernel_ as follows:

metis:~ # netstat -rn
Kernel routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 0.0.0.0 255.255.255.255 UH 1500 0 0 eth0
127.0.0.1 0.0.0.0 255.255.255.255 UH 3584 0 0 lo
129.78.97.192 0.0.0.0 255.255.255.248 U 1500 0 0 eth0

With a very strange default route with an all ones netmask. Adding my standard
default route works and produces a table like this

metis:~ # netstat -rn
Kernel routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 0.0.0.0 255.255.255.255 UH 1500 0 0 eth0
127.0.0.1 0.0.0.0 255.255.255.255 UH 3584 0 0 lo
129.78.97.192 0.0.0.0 255.255.255.248 U 1500 0 0 eth0
0.0.0.0 129.78.97.193 0.0.0.0 UG 1500 0 0 eth0

and if I get silly and add that other strange route, I can get
metis:~ # netstat -rn
Kernel routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 0.0.0.0 255.255.255.255 UH 1500 0 0 eth0
127.0.0.1 0.0.0.0 255.255.255.255 UH 3584 0 0 lo
129.78.97.192 0.0.0.0 255.255.255.248 U 1500 0 0 eth0
0.0.0.0 0.0.0.0 0.0.0.0 U 1500 0 0 eth0
0.0.0.0 129.78.97.193 0.0.0.0 UG 1500 0 0 eth0

which seems a little odd.

In fact I seem to be able to add as many default routes as I like all with
different gateways, as long as I add the bizzare default route with no gateway
inbetween:

elara:~ # route add -net default gw 129.78.97.193 dev eth0
elara:~ # route add -net default gw 200.0.0.0 dev eth0
SIOCADDRT: Invalid argument
elara:~ # route add -net default dev eth0
elara:~ # route add -net default gw 200.0.0.0 dev eth0
elara:~ # route add -net default dev eth0
elara:~ # route add -net default gw 201.0.0.0 dev eth0
elara:~ # route add -net default dev eth0
elara:~ # route add -net default gw 202.0.0.0 dev eth0
elara:~ # netstat -rn
Kernel routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
129.78.97.192 0.0.0.0 255.255.255.248 U 0 0 45 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 5 lo
0.0.0.0 202.0.0.0 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 eth0
0.0.0.0 201.0.0.0 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 200.0.0.0 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 129.78.97.193 0.0.0.0 UG 0 0 0 eth0

Ouch. The route with the null gateway seems to propagate up the table and allow
adding further default routes at will - very strange. This works on both the
1.3.100 and pre2.0.2 boxen.

David