Subject: Re: Stopping dhclient does not restore /etc/resolv.conf
To: None <netbsd-help@netbsd.org>
From: Gregoire Sutre <sutre@labri.fr>
List: netbsd-help
Date: 10/29/2003 00:32:32
On Tue, Oct 28, 2003 at 12:01:54PM +0100, Gr=E9goire Sutre wrote:
> Hi,
>=20
> I expected that stopping dhclient would restore the saved /etc/resolv.c=
onf=20
> (named /etc/resolv.conf.save), however this is not the case on my NetBS=
D=20
> 1.6.1_STABLE (i386) box.
>=20
> It seems that /sbin/dhclient-script is designed to restore /etc/resolv.=
conf,=20
> when called with $reason =3D STOP.
>=20
> However, when I stop dhclient (with /etc/rc.d/dhclient stop), dhclient-=
script
> is not called and hence can not do its job.
After some experiments, it turns out that the -r flag allows to "cleanly"
shutdown dhclient. The man page says:
The client normally doesn't release the current lease as it is no=
t
required by the DHCP protocol. Some cable ISPs require their client=
s
to notify the server if they wish to release an assigned IP address=
.
The -r flag explicitly releases the current lease, and once the leas=
e
has been released, the client exits.
In particular, dhclient -r calls dhclient-script which (among other thing=
s)
restores the saved /etc/resolv.conf.
So I intend to add the following line in /etc/rc.d/dhclient:
stop_cmd=3D"$command -r"
where $command is previously set to /sbin/dhclient (in /etc/rc.d/dhclient=
).
As I'm new to NetBSD, I would appreciate if an experienced user could con=
firm
that I won't introduce problems with this "fix".
Many thanks,
Gregoire.