Skip to contentSkip to conversation

semi OT: default route

DISCUSSION Payal Rathod 4 participants 7 messages Oct 20, 2004 – Oct 22, 2004

lore
Share & tools
lore
#0 lore raw

Hi,
I have a question which has haunted me for many months. If I have 2 ISP connections with me, with default gw 1.2.3.4 and 4.5.6.7 and if I add both as default routes on my Linux gateway as,
route add -net default gw 1.2.3.4
route add -net default gw 4.5.6.7
and if I send a packet from a windows client to internet, which ISP will it go through?

Thanks a lot for the answer in advance and waiting eagerly for any replies.

With warm regards,
-Payal

#1 lore raw
Quoted 8 lines · Payal Rathod

Hi,
I have a question which has haunted me for many months. If I have 2 ISP connections with me, with default gw 1.2.3.4 and 4.5.6.7 and if I add both as default routes on my Linux gateway as,
route add -net default gw 1.2.3.4
route add -net default gw 4.5.6.7
and if I send a packet from a windows client to internet, which ISP will it go through?

this will sound like a stupid answer, but it will probably always use the route that you added first. the 'route' command will allow you to added multiple default routes, but the ones you add after the first one end up getting ignored. the 'ip' command won't let you add a default route once you have one (it uses teq and multipath for this):

	$ ip route list | grep default
	default via 10.2.1.1 dev eth0
	$ sudo ip route add default via 10.2.1.2
	RTNETLINK answers: File exists

if you want to load-balance outbound traffic over multiple ISP links, you'll want to use something along the lines of the 'nth' patch from POM:

http://netfilter.org/documentation/HOWTO/netfilter-extensions-HOWTO-3.html#ss3.9

if you want to split outbound traffic over multiple links by source IP or protocol, etc--you can use the concepts from:

http://lartc.org/howto/lartc.netfilter.html

-j

Signature · 1 line
Jason Opperisano <[email protected]>
#2 lore raw
Quoted 9 lines · Jason Opperisano
Quoted 8 lines · Payal Rathod

Hi,
I have a question which has haunted me for many months. If I have 2 ISP connections with me, with default gw 1.2.3.4 and 4.5.6.7 and if I add both as default routes on my Linux gateway as,
route add -net default gw 1.2.3.4
route add -net default gw 4.5.6.7
and if I send a packet from a windows client to internet, which ISP will it go through?

Looking at this from a slightly different, well, simpler, point of view than Jason...

Quoted 2 lines

this will sound like a stupid answer, but it will probably always use the route that you added first.

On the host I've just tried this on - admittedly just the once, it tried the route I added *last*. But this is about thirty seconds worth of testing :)

Quoted 10 lines

the 'route' command will allow you to added multiple default routes, but the ones you add after the first one end up getting ignored. the 'ip' command won't let you add a default route once you have one (it uses teq and multipath for this):

	$ ip route list | grep default
	default via 10.2.1.1 dev eth0
	$ sudo ip route add default via 10.2.1.2
	RTNETLINK answers: File exists

However if you want to give the routes different metrics....

ip route add default via 1.2.3.4 metric 1
ip route add default via 4.5.6.7 metric 2

"ip" will accept that input.

That should mean if the host can't send the traffic via 1.2.3.4 it will realise this ( I presume solely if it gets no arp-reply for 1.2.3.4) it will try and send the traffic via 4.5.6.7 instead.

That seems to be the way it should work, however on a test box my host is happily trying to arp for 1.2.3.4 continuosly.

Anyone help me finish off this answer ;)

Signature · 4 lines
We are the Willing, led by the Unknowing,
Are doing the Impossible, for the Ungrateful.
We have done so much, for so long, with so little,
We are now qualified to do anything with nothing.
#3 lore raw
Quoted 7 lines · Nick Drage

However if you want to give the routes different metrics....

ip route add default via 1.2.3.4 metric 1
ip route add default via 4.5.6.7 metric 2

"ip" will accept that input.

Quoted 8 lines

That should mean if the host can't send the traffic via 1.2.3.4 it will realise this ( I presume solely if it gets no arp-reply for 1.2.3.4) it will try and send the traffic via 4.5.6.7 instead.

That seems to be the way it should work, however on a test box my host is happily trying to arp for 1.2.3.4 continuosly.

Anyone help me finish off this answer ;)

yes--the linux routing code will do dead gateway detection and fall back to a lower metric route in the event of failure, and also go back to the higher metric route upon resurrection. this can be useful for an active-standby setup.

as for which route added by 'route' actually gets used--i've never spent the time to figure out how it picks the one it uses, but it certainly only appears to ever use one--maybe it picks the one with the lowest numerical value... or maybe it uses one of those magic 8-ball things...

-j

Signature · 1 line
Jason Opperisano <[email protected]>
#4 lore raw
Quoted 4 lines · Jason Opperisano

yes--the linux routing code will do dead gateway detection and fall back to a lower metric route in the event of failure, and also go back to the higher metric route upon resurrection. this can be useful for an active-standby setup.

routed might help here. Right?
Can anyone with 2 ISP setup please check the load balance thing? I vaguely remember seeing something about multiple default routes in early chapters of TCP/IP Illustrated Vol. 1 (I am not at all sure). Thanks.
With warm regards,
-Payal

#5 lore raw
Quoted 7 lines · Payal Rathod
Quoted 4 lines · Jason Opperisano

yes--the linux routing code will do dead gateway detection and fall back to a lower metric route in the event of failure, and also go back to the higher metric route upon resurrection. this can be useful for an active-standby setup.

routed might help here. Right?

no--routed is a method for learning routes. you already know what the routes are. you're looking for a method to balance traffic over two physical links. the solution to that goal is more complicated than just adding two default gateways.

-j

Signature · 1 line
Jason Opperisano <[email protected]>
#6 lore raw

multiple external interface ?

In reply to Jason Opperisano

Is it possible in iptables to have more then one external interfaces ? I am going to run a webproxy server with iptables enabled with NAT & for that i want to increase my bandwith in doing so ...

thanks