2002-01-06 20:26:39

by Dave Zarzycki

[permalink] [raw]
Subject: In kernel routing table vs. /sbin/ip vs. /sbin/route

Using /sbin/route, I can add multiple default routes like so:

/sbin/route add -net default gw 192.168.0.1
/sbin/route add -net default gw 192.168.0.2

But I cannot do the same with /sbin/ip:

/sbin/ip route add default via 192.168.0.1
/sbin/ip route add default via 192.168.0.2
RTNETLINK answers: File exists

Given that /sbin/ip is the more powerful and modern tool, I'm lead to
believe that /sbin/route might be leaving the in kernel routing table in a
weird state.

My two simple questions are as follows:

1) Which tool is more correct?

2) What is the behavior of the kernel when multiple default routes are
defined?

Thanks,

davez

--
Dave Zarzycki
http://zarzycki.org/~dave/


2002-01-06 21:37:12

by Martin Schewe

[permalink] [raw]
Subject: Re: In kernel routing table vs. /sbin/ip vs. /sbin/route

Hi,

On Sun, Jan 06, 2002 at 12:23:50PM -0800, Dave Zarzycki wrote:
> Using /sbin/route, I can add multiple default routes like so:
>
> /sbin/route add -net default gw 192.168.0.1
> /sbin/route add -net default gw 192.168.0.2
>
> But I cannot do the same with /sbin/ip:
>
> /sbin/ip route add default via 192.168.0.1
> /sbin/ip route add default via 192.168.0.2
> RTNETLINK answers: File exists

$ /sbin/ip route append default via 192.168.0.2

> Given that /sbin/ip is the more powerful and modern tool, I'm lead to
> believe that /sbin/route might be leaving the in kernel routing table
> in a weird state.
>
> My two simple questions are as follows:
>
> 1) Which tool is more correct?

RFC1122 says having several _default_ routes is okay.

> 2) What is the behavior of the kernel when multiple default routes are
> defined?

The kernel will make dead gateway detection to select the right one for
you.

Regards,
Martin


Attachments:
(No filename) (925.00 B)
(No filename) (240.00 B)
Download all attachments