Subject: Re: dhclient erases(!?) /etc/resolv.conf (fwd)
To: None <netbsd-help@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: netbsd-help
Date: 04/02/2002 17:52:44
In article <Pine.GSO.4.33.0204011738540.26721-100000@math.rice.edu>,
Richard Rauch <rauch@rice.edu> wrote:
>> > I decided to try running dhclient on my laptop in a different environment
>> > today. I was disturbed to discover that dhclient appears to have
>> > oblitterated my old /etc/resolv.conf (rather blindly), and did not restore
> [...]
>> > Is this an intended feature, or was it just that no one considered that
> [...]
>> Well, i guess it's intended.
>> In /sbin/dhclient-script (or /etc/....):
> [...]
>
>Yes, it does seem that the script is oblitterating the old file.
>
>The question is: Is this a matter of oversight, or is there some good
>reason to erase (without warning, etc.) your static configuration?
>
>It appears that dhclient-script's EXITHOOKS/ENTERHOOKS handling will let
>me install hooks to preserve my static configuration. I think that
>something along these lines should be done in the default DHCP behavior.
>That, or dhclient[-script] should document the destruction of static data
>in the BUGS section. (dhclient-script documents a related situation with
>resolv.conf, with regard to running multiple dhclients on one machine.
>But that's not really considered to be a bug, and indeed apparently causes
>no harm in that case.)
>
>My outlined solution:
>
> * *Mark* DHCP-generated files (where possible). E.g., resolv.conf
> should have a ``# automatically generated by dhclient-script'' at
> the top, or similar. (I'm not sure what other files might be
> created by DHCP, now or in the future. Take this as a general
> comment. (^&)
Fine.
> * For resolv.conf in particular, on entry to dhclient-script:
>
> if $RESOLV exists and isn't DHCP-generated
> mv $RESOLV $RESOLV.static
$RESOLV.save
> * For resolv.conf in particular, on exit_with_hooks in dhclient-script:
>
> if $RESOLV.static exists
> mv $RESOLV.static $RESOLV
> else if $RESOLV exists and is DHCP-generated
> rm $RESOLV
Will not work because the scripts is not called when you kill dhclient.
christos