Discussion:
dhclient-script: trying harder to set correct default route
(too old to reply)
Christoph Badura
2010-02-10 19:18:47 UTC
Permalink
The following behaviour has been annoying me for a long time and I had
the appended patch in my local trees for a couple of years.

When dhclient runs dhclient-script after binding to set the new IP address
and default route (among other things), it fails to set the new default route
if there already exists a default route in the system. I get that situation
regularly when restarting dhclient.

Does anyone object to the following patch? I asked Ted Lemon about it
and he said it is OK with him.

Index: clientscript/dhclient-script
===================================================================
RCS file: /cvsroot/src/usr.sbin/dhcp/clientscript/dhclient-script,v
retrieving revision 1.13
diff -u -r1.13 dhclient-script
--- clientscript/dhclient-script 21 Nov 2009 07:53:59 -0000 1.13
+++ clientscript/dhclient-script 10 Feb 2010 19:36:53 -0000
@@ -64,7 +64,8 @@

add_new_routes() {
for router in $new_routers; do
- route add default $router
+ route add default $router ||
+ route change default $router
done >/dev/null 2>&1

set -- $new_static_routes

--chris

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
David Young
2010-02-10 20:12:11 UTC
Permalink
Post by Christoph Badura
The following behaviour has been annoying me for a long time and I had
the appended patch in my local trees for a couple of years.
When dhclient runs dhclient-script after binding to set the new IP address
and default route (among other things), it fails to set the new default route
if there already exists a default route in the system. I get that situation
regularly when restarting dhclient.
Does anyone object to the following patch? I asked Ted Lemon about it
and he said it is OK with him.
Your patch is a very good idea. I have run a similar patch for a long
time. I haven't found any downside.

Dave
--
David Young OJC Technologies
***@ojctech.com Urbana, IL * (217) 278-3933

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Matthias Drochner
2010-02-10 20:19:13 UTC
Permalink
Post by David Young
Post by Christoph Badura
it fails to set the new default route
if there already exists a default route in the system
Your patch is a very good idea
I think so too -- although I'm using dhcpcd on -current now
which generally deals well with network connection changes.

A possibly related question: I've seen recommendations like
this:
route add -inet6 default ::1
route change -inet6 default -ifp $int
at various places (the quote is from the sixxs.net FAQ).
Can someone explain why this is better than adding
the route directly?

best regards
Matthias



------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Steven Bellovin
2010-02-10 20:25:26 UTC
Permalink
Post by Christoph Badura
The following behaviour has been annoying me for a long time and I had
the appended patch in my local trees for a couple of years.
When dhclient runs dhclient-script after binding to set the new IP address
and default route (among other things), it fails to set the new default route
if there already exists a default route in the system. I get that situation
regularly when restarting dhclient.
Does anyone object to the following patch? I asked Ted Lemon about it
and he said it is OK with him.
I think it's an excellent change. I think, btw, that pppd (through its scripts) has a similar problem, though at the moment I can neither find the source to default scripts (if there is indeed a default) nor recall where I got the scripts that I'm using.

--Steve Bellovin, http://www.cs.columbia.edu/~smb






--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Robert Elz
2010-02-11 11:18:22 UTC
Permalink
Date: Wed, 10 Feb 2010 20:18:47 +0100
From: Christoph Badura <***@bsd.de>
Message-ID: <***@irregular-apocalypse.k.bsd.de>

| Does anyone object to the following patch?

If what is happening is that you're updating an old lease, it is the
obvious correct thing to do, though, in theory, the old default route
should be removed before the attempt is made to install the new one anyway
(that's what I recall the script I uses doing.)

I have a slightly different problem - I have two interfaces, wired, and
wireless, and when wired is available, I generally plug it in (faster
and all that...) - but disabling wireless is too painful, so I just leave
that running as well.

I end up getting default routes from both of them - one after the other
at about the same time. Fortunately (for this patch, for me) for
whatever reason, the wireless one always seems to come first, then
dhclient is unable to install the one from the wired net (so your patch
would be just fine with me.)

If I was unlucky, and the wired one was installed first, and your patch
allowed it to be altered to the other one, I'd be less happy...
(we really need better config with a "default interface preference" or
something, so it is possible to define which interface's default route
is preferred.)

I can't just not ask for the default route from dhcp, as when I start
I have no idea which of the two links will actually work (not all locations
have wireless, not all locations have wires).


***@fz-juelich.de said:
| A possibly related question: I've seen recommendations like this:
| route add -inet6 default ::1
| route change -inet6 default -ifp $int
| at various places (the quote is from the sixxs.net FAQ).
| Can someone explain why this is better than adding the route directly?

The theory (I believe) is that it allows you to specify which interface you
want your default route to run out of (if you have only one, you don't need
that), but then allow router advertisements to actually supply the address of
the available router(s) to use for the default route (ie: you never actually
need to configure the IPv6 (LL) address to use, but you still get to choose
which interface is the right way out of your system.)

If you mean why "route add" and then "route change" - that's just covering
up bugs in the system - route add with an interface has never worked reliably,
but route change always has.

kre




--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
der Mouse
2010-02-11 11:35:01 UTC
Permalink
Post by Robert Elz
I have a slightly different problem - I have two interfaces, wired,
and wireless, [...]
I can't just not ask for the default route from dhcp, as when I start
I have no idea which of the two links will actually work (not all
locations have wireless, not all locations have wires).
This sounds to me like exactly the sort of reason dhclient-script is a
script: so that you can add local intelligence to it easily. Sounds to
me as tbhough you want to record which intefaces have given you default
routes and then apply some defaulting rules to figure out which route
to install in the kernel. I would not expect the DHCP software to get
this right out of the box, since "right" is very you-specific.

Not very relevant to the proposed change, though, which amounts to a
decision as to what the DHCP client should do by default.

/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML ***@rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Joerg Sonnenberger
2010-02-11 11:37:39 UTC
Permalink
Post by Robert Elz
I have a slightly different problem - I have two interfaces, wired, and
wireless, and when wired is available, I generally plug it in (faster
and all that...) - but disabling wireless is too painful, so I just leave
that running as well.
Use dhcpcd. It handles that case OoB -- here, it takes care of the
default route for ppp0, bge0 and wpi0 with that preference. Very handy
:)

Joerg

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...