Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dhclient insist in erasing resolv.conf

192 views
Skip to first unread message

Rodericus

unread,
Oct 20, 2011, 4:19:59 AM10/20/11
to
I followed th instructions in

http://www.openbsd.org/faq/faq6.html#DHCPclient

uncommented request and earrased "domain-name-servers", but dhcp
insist in changing
resolv.conf and also in giving an unwanted DNS server. Why?

Do you know a real solution (not resolv.conf.tail) so that I decide
what in resolv.conf
stay? So that dhclient do not touch resolv.conf?

Thanks
Rodrigo

<begin quote>
No matter how you start the DHCP client, you can edit the /etc/
dhclient.conf file to not
update your DNS according to the dhcp server's idea of DNS by first
uncommenting the
'request' lines in it (they are examples of the default settings, but
you need to uncomment
them to override dhclient's defaults.)

request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name, lpr-servers,
ntp-servers;

and then remove domain-name-servers. Of course, you may want to remove
host-name,
or other settings too.
<end of quote>

Rodericus

unread,
Oct 20, 2011, 5:04:30 AM10/20/11
to
By the way, I put "lookup file bind" in resolv.conf.tail, dhclient
appends it to
resolv.conf, but after reboot the appended line disappers. Why?!

This behauvios is like windows: the computer pretens to know what
the user wants and do unwanted, not understandable things.

The only thing I want is to have alway the same resolv.conf, online
and offline, an untouched resolv.conf. I want to decide what goes
there.

Rodrigo

Carson Chittom

unread,
Oct 20, 2011, 12:45:23 PM10/20/11
to
Rodericus <sc...@web.de> writes:

> The only thing I want is to have alway the same resolv.conf, online
> and offline, an untouched resolv.conf. I want to decide what goes
> there.

Look at dhclient.conf(5) for the "supersede" option modifier. You want
something like

supersede domain-name-servers "127.0.0.1";

in /etc/dhclient.conf, which would give you a resolv.conf of

nameserver 127.0.0.1

--
http://www.wistly.net

Rodericus

unread,
Oct 21, 2011, 5:05:49 AM10/21/11
to
On Oct 20, 4:45 pm, Carson Chittom <car...@wistly.net> wrote:

> supersede domain-name-servers "127.0.0.1";

That is not enough. dhclient makes a new resolv.conf,
it errases what I want, it adds what I dont want, not
all what I want is so easy to rech as with a "supersede".
And instead of reaching what I want in resolv.conf
with tricks on dhclient, I prefer to just write resolv.conf
as I want.

Rod.

Carson Chittom

unread,
Oct 22, 2011, 9:05:33 AM10/22/11
to
Rodericus <sc...@web.de> writes:

> On Oct 20, 4:45 pm, Carson Chittom <car...@wistly.net> wrote:
>
>> supersede domain-name-servers "127.0.0.1";
>
> That is not enough. dhclient makes a new resolv.conf
> it errases what I want, it adds what I dont want, not
> all what I want is so easy to rech as with a "supersede".
> And instead of reaching what I want in resolv.conf
> with tricks on dhclient, I prefer to just write resolv.conf
> as I want.

It's not "tricks"; it's DHCP working as designed. The mechanism to
"just write resolv.conf as I want" is to use dhclient.conf(5) and
resolv.conf.tail(5). Why do you care how often resolv.conf gets
recreated, as long as its contents are accurate? Does it really matter?


--
http://www.wistly.net

Torfinn Ingolfsen

unread,
Jan 30, 2012, 7:25:46 PM1/30/12
to
Does OpenBSD use the ISC DHCP client?
If so, this might work (I am using it with FreeBSD).
Create a file /etc/dhclient-enter-hooks, with this content:
# avoid overwriting /etc/resolv.conf
add_new_resolv_conf() {
# We don't want /etc/resolv.conf changed
# So this is an empty function
return 0
}

I found the solution on the FreeBSD forums, the idea is not mine.
HTH
--
Torfinn Ingolfsen,
Norway

Joachim Schipper

unread,
Jan 31, 2012, 2:48:32 AM1/31/12
to
OpenBSD uses a hacked old version. The above won't work.

If you insist, you can write your own dhclient-script (it's fairly
obvious which function you need to change). I don't think there are any
actual resolv.conf options you cannot change with supersede and
resolv.conf.tail, though.

Joachim
0 new messages