Networking Forums

Networking Forums > Computer Networking > Linux Networking > Two default gw in kernel routing table

Reply
Thread Tools Display Modes

Two default gw in kernel routing table

 
 
Binary
Guest
Posts: n/a

 
      02-12-2007, 09:47 AM
Hi,

If I have two default gw in kernel routing table, in any given time,
which rule will be used first? The same as displayed in route command?
Or has a random order, each one will have the oppotunity to be used?
Or each time both will be tried?

Thanks.
ABAI

 
Reply With Quote
 
 
 
 
Moe Trin
Guest
Posts: n/a

 
      02-12-2007, 07:16 PM
On 12 Feb 2007, in the Usenet newsgroup comp.os.linux.networking, in article
<(E-Mail Removed) .com>, Binary wrote:

>If I have two default gw in kernel routing table, in any given time,


you will run into problems.

>which rule will be used first?


The one with the lower metric. Assuming the metrics are the same, then
the _last_ defined route will be used, because there kernel assumes you
changed your mind and thought of a better solution. The other "default"
routes will be ignored.

>The same as displayed in route command? Or has a random order, each
>one will have the oppotunity to be used? Or each time both will be tried?


Rather than guessing - you _could_ try using a search engine, as this
question is constantly asked again, and again, and again, and again, and...

I'm guessing that English isn't your first language. The word "default"
has a number of meanings - and the common dictionary meanings are not
the one used in networking. Rather, the meaning is that of the programmer
when given a choice or selection. If choice "A" is best, use choice "A".
If choice "B" is best, use choice "B". If choice "C" is best, use choice
"C". If neither "A", "B", or "C" is correct, use the "default". This
means that there can only be _one_ default.

Old guy
 
Reply With Quote
 
Floyd L. Davidson
Guest
Posts: n/a

 
      02-12-2007, 07:39 PM
(E-Mail Removed) (Moe Trin) wrote:
>On 12 Feb 2007, in the Usenet newsgroup comp.os.linux.networking, in article
><(E-Mail Removed) s.com>, Binary wrote:
>
>>If I have two default gw in kernel routing table, in any given time,

>
>you will run into problems.


Not really... ;-)

>>which rule will be used first?

>
>The one with the lower metric. Assuming the metrics are the same, then
>the _last_ defined route will be used, because there kernel assumes you
>changed your mind and thought of a better solution. The other "default"
>routes will be ignored.
>
>>The same as displayed in route command? Or has a random order, each
>>one will have the oppotunity to be used? Or each time both will be tried?


Use the "route" command to see what the kernel route table looks
like. The route used for any given destination is the *first*
one that matches as it scans down the routing table. Hence, if
you have two "default" routes, one of the them will *never* be
reached, because everything that makes it all the way to the
first "default" will in fact be routed by that entry.

--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) (E-Mail Removed)
 
Reply With Quote
 
M4teK
Guest
Posts: n/a

 
      02-12-2007, 07:50 PM
> >>If I have two default gw in kernel routing table, in any given time,
>
> >you will run into problems.

>
> Not really... ;-)
>
> >>which rule will be used first?

>
> >The one with the lower metric. Assuming the metrics are the same, then
> >the _last_ defined route will be used, because there kernel assumes you
> >changed your mind and thought of a better solution. The other "default"
> >routes will be ignored.

>
> >>The same as displayed in route command? Or has a random order, each
> >>one will have the oppotunity to be used? Or each time both will be tried?

>
> Use the "route" command to see what the kernel route table looks
> like. The route used for any given destination is the *first*
> one that matches as it scans down the routing table. Hence, if
> you have two "default" routes, one of the them will *never* be
> reached, because everything that makes it all the way to the
> first "default" will in fact be routed by that entry.
>
> --
> Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>


I'm wondering what U mean writing multiple default routes.
Look here
<code>
root@sdnet:~# ip r s
default
nexthop via 193.X.X.X dev eth2 weight 1
nexthop via 80.Y.Y.X dev eth3 weight 1
</code>
It's some snap form my running routing table.
Metrics are the same, none of default routes is never, because both
are added by one command.
So what now?
Route via dev eth2 will always be used? No!
Linux will use both of then dividing traffic between links in
proportion shown by weights.

HF
MR

 
Reply With Quote
 
Unruh
Guest
Posts: n/a

 
      02-13-2007, 05:50 PM
"Binary" <(E-Mail Removed)> writes:

>Hi,


>If I have two default gw in kernel routing table, in any given time,
>which rule will be used first? The same as displayed in route command?


No first. There is only one. the last one implimented. There is never any
other used.

>Or has a random order, each one will have the oppotunity to be used?
>Or each time both will be tried?


HOw would it do that?


>Thanks.
>ABAI


 
Reply With Quote
 
Steve Thompson
Guest
Posts: n/a

 
      02-13-2007, 06:36 PM
On Mon, 12 Feb 2007, Floyd L. Davidson wrote:

> Use the "route" command to see what the kernel route table looks
> like. The route used for any given destination is the *first*
> one that matches as it scans down the routing table. Hence, if
> you have two "default" routes, one of the them will *never* be
> reached, because everything that makes it all the way to the
> first "default" will in fact be routed by that entry.


I'm told (google) that the second one would get used if the first gateway
drops dead. Is that wrong?

-s
 
Reply With Quote
 
Moe Trin
Guest
Posts: n/a

 
      02-13-2007, 06:54 PM
On 12 Feb 2007, in the Usenet newsgroup comp.os.linux.networking, in article
<(E-Mail Removed). com>, M4teK wrote:

>>>> If I have two default gw in kernel routing table, in any given time,

>>
>>> you will run into problems.

>>
>> Not really... ;-)


Web Results 1 - 10 of about 20,300,000 for Linux two+default. (0.12
seconds)

Web Results 1 - 10 of about 1,110,000 for Linux two+default+gateway.
(0.14 seconds)

Web Results 1 - 10 of about 1,130,000 for Linux two+default+route.
(0.10 seconds)

Yeah - no one EVER has problems with two default routes.

>> Use the "route" command to see what the kernel route table looks
>> like. The route used for any given destination is the *first*
>> one that matches as it scans down the routing table.


>I'm wondering what U mean writing multiple default routes.


I'm wondering what you mean?

>Look here
><code>
>root@sdnet:~# ip r s


'/sbin/ip' is not the '/sbin/route' command. You'll want to re-read the
ip-cref document.

> nexthop via 193.X.X.X dev eth2 weight 1
> nexthop via 80.Y.Y.X dev eth3 weight 1
></code>
>It's some snap form my running routing table.
>Metrics are the same, none of default routes is never, because both
>are added by one command.
>So what now?
>Route via dev eth2 will always be used? No!
>Linux will use both of then dividing traffic between links in
>proportion shown by weights.


See the Advanced Routing HOWTO for additional details. Your routing
table is lacking the policy information.

Old guy

 
Reply With Quote
 
Moe Trin
Guest
Posts: n/a

 
      02-13-2007, 06:56 PM
On Tue, 13 Feb 2007, in the Usenet newsgroup comp.os.linux.networking, in
article <(E-Mail Removed). com>, Steve Thompson
wrote:

>Floyd L. Davidson wrote:


>> Use the "route" command to see what the kernel route table looks
>> like. The route used for any given destination is the *first*
>> one that matches as it scans down the routing table. Hence, if
>> you have two "default" routes, one of the them will *never* be
>> reached, because everything that makes it all the way to the
>> first "default" will in fact be routed by that entry.

>
>I'm told (google) that the second one would get used if the first gateway
>drops dead. Is that wrong?


Only if you are using a routing daemon, such as 'routed' or 'gated' to
manage your routing table. Of course, the Advanced Routing HOWTO can
let you do "interesting" things in load-balancing, but that's not a
very common setup.

Old guy

 
Reply With Quote
 
Unruh
Guest
Posts: n/a

 
      02-14-2007, 07:08 AM
Steve Thompson <(E-Mail Removed)> writes:

>On Mon, 12 Feb 2007, Floyd L. Davidson wrote:


>> Use the "route" command to see what the kernel route table looks
>> like. The route used for any given destination is the *first*
>> one that matches as it scans down the routing table. Hence, if
>> you have two "default" routes, one of the them will *never* be
>> reached, because everything that makes it all the way to the
>> first "default" will in fact be routed by that entry.


>I'm told (google) that the second one would get used if the first gateway
>drops dead. Is that wrong?


How does it "drop dead"? I have no idea if it would fall back, but I doubt
it. Why not try it? choose as your second gateway some non-existant IP and
see if there is any fallback.



 
Reply With Quote
 
Unruh
Guest
Posts: n/a

 
      02-14-2007, 07:15 AM
(E-Mail Removed) (Moe Trin) writes:

>On 12 Feb 2007, in the Usenet newsgroup comp.os.linux.networking, in article
><(E-Mail Removed) .com>, M4teK wrote:


>>>>> If I have two default gw in kernel routing table, in any given time,
>>>
>>>> you will run into problems.
>>>
>>> Not really... ;-)


> Web Results 1 - 10 of about 20,300,000 for Linux two+default. (0.12
> seconds)


> Web Results 1 - 10 of about 1,110,000 for Linux two+default+gateway.
> (0.14 seconds)


> Web Results 1 - 10 of about 1,130,000 for Linux two+default+route.
> (0.10 seconds)


>Yeah - no one EVER has problems with two default routes.


>>> Use the "route" command to see what the kernel route table looks
>>> like. The route used for any given destination is the *first*
>>> one that matches as it scans down the routing table.


>>I'm wondering what U mean writing multiple default routes.


>I'm wondering what you mean?


>>Look here
>><code>
>>root@sdnet:~# ip r s


>'/sbin/ip' is not the '/sbin/route' command. You'll want to re-read the
>ip-cref document.


>> nexthop via 193.X.X.X dev eth2 weight 1
>> nexthop via 80.Y.Y.X dev eth3 weight 1
>></code>
>>It's some snap form my running routing table.
>>Metrics are the same, none of default routes is never, because both
>>are added by one command.
>>So what now?
>>Route via dev eth2 will always be used? No!
>>Linux will use both of then dividing traffic between links in
>>proportion shown by weights.


>See the Advanced Routing HOWTO for additional details. Your routing
>table is lacking the policy information.


> Old guy



Just tried it. I added a second default route to my system with the gateway
being a non-existant IP on my second network I thus had two routes. I now
tried to get to some machine. I could not. It did NOT use the other default
route. It tried to use the non-existant gateway, and told me it could not
get to it. Using two default routes does not work. There is onlyone default
route-- the last one added. And if it dies, your routing dies with it.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel IP Routing Table Alex Bell Linux Networking 2 06-01-2005 11:33 AM
how to set default entry in routing table? kernel.lover Linux Networking 1 03-15-2005 10:40 PM
How to use second routing table? Martin Pauly Linux Networking 0 03-08-2005 04:54 PM
How do I access the routing table from the kernel? Carl-Gustaf Wennstrom IB Linux Networking 1 10-03-2003 01:35 PM
kernel limit on # of MAC addresses on firewall? --Neighbour Table Overflow Jones Linux Networking 0 09-18-2003 04:34 PM



1 2 3 4 5 6 7 8 9 10 11