The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
resolv.conf is being modified, and not by me (a DHCP problem) 29 July 1998
Need more help on this topic? Click here
This article has 5 comments
Show me similar articles
This problem occurred because DHCP overwrites the contents of resolv.conf. and I didn't know that.  But you have quite a bit of control over what DHCP puts into that file.   Details are below.
29 July 1998
After my reboot as a result of my floppy disk mount exploits, I found that the contents of resolv.conf had been modified.
What is dhcp?
DHCP (Dynamic Host Configuration Protocol ) is defined in RFCs 2131 and 2132 and provides a client with a complete set of TCP/IP configuration values.  In short, it allows a client to obtain, among other things, an IP number, the name of the domain, and a list of name servers.

I recommend you read the following book: TCP/IP Network Administration by Craig Hunt and published by O'Reilly,   ISBN 1-56592-322-7.  This book is also known as the crab book (you'll know why when you see the cover).

The problem
As mentioned above, I noticed a minor but very irritating problem.  Whenever the name was rebooted, the contents of resolv.conf would change and manual modification was needed in order for the system to resolve names again.
What appeared after a reboot:
search myisp.com
nameserver 11.22.33.44
nameserver 11.22.33.45
What I wanted:
domain www.example.org
nameserver 10.0.0.1	# my min-dns server
nameserver 11.22.33.44
nameserver 11.22.33.45
31 July 1998
It turns out that DHCP client will rewrite the contents of resolv.conf with the information it obtains from the DHCP server.  Well, that's not good enough.

Here's what resolv.conf contains after a reboot:

search myisp.com
nameserver 11.22.33.44
nameserver 11.22.33.45

Here's what I want it to contain:

domain www.example.org
nameserver 10.0.0.10		# my min-dns server
nameserver 11.22.33.44
nameserver 11.22.33.45

I'll report back after I get this solved.  The reason I want the above is related to my name server.

1 August 1998
White rabbits.

The message from the mailing list mentions the prepend command and to check out man dhclient.conf.  What I find there is I need to do something like:

prepend {
 domain-name "www.example.org";
 domain-name-servers 10.0.1.4;
}

I tried that.  Then did the following to restart dhclient:

bash# cat /var/run/dhclient.pid
5676
bash# kill -9 5676
bash# dhclient ed0

The prepend command I used gave syntax errors.  And my ed1 link died.  So I issued:

ifconfig ed1 inet 10.0.0.1 255.255.255.0

After several attempts. No luck.

prepend domain-name "www.example.org";

Neah.  Still doesn't work.


Checking the documentation....
The example provided by man dhclient.conf shows the prepend statement within the interface "ep0" {...} statement.  I found this didn't work for me and no effect on the contents of /etc/resolv.conf.  My next attempt involved moving the prepend command to be above the interface command.

Ahuh!

Now I'm getting the following /etc/resolv.conf file:

search www.example.orgmyisp.com
nameserver 10.0.0.1
nameserver 11.22.33.44
nameserver 11.22.33.45

For some reason the domain-name request is being prepended to the search statement.  Very weird.  I'd like to remove the request statement altogether.   There is something in the manual about that.  I'll check that again....

I tried removing the domain-name option from the interface statement.  That seemed to have nil effect.

I'm lost.  I found nothing in the mailing list archives.  And http://www.dejan.com had nothing either.   I'll ask the mailing list again.

8 August 1998
It has been recommended that I try the following command (note the extra space in the quoted string):
prepend domain-name "www.example.org "

After restarting dhclient, /etc/resolv.conf contains the following:

search www.example.org myisp.com
nameserver 10.0.0.1
nameserver 11.22.33.44
nameserver 11.22.33.45

Note: I still need to do the following to get ed1 running after restarting dhclient:

ifconfig ed1 inet 10.0.0.1 255.255.255.0

So the next thing I try doing is the supersede command:

supersede domain-name "www.example.org "

OK!  That gives me:

search www.example.org
nameserver 10.0.0.1
nameserver 11.22.33.44
nameserver 11.22.33.45

This works.  The names resolve nicely.  I don't have to manually change /etc/resolv.conf after a reboot.

Now, how to swap domain for search in the above?  Do I want to?

dhclient.conf 16 October 1998
A recent email prompted me to add my /etc/dhclient.conf file to the website.  It might help.
/etc/dhclient-enter-hooks 20 November 2002
See also http://www.netbsd.org/Documentation/network/dhcp.html#keep_resolv_conf which recommends this file:
# cat /etc/dhclient-enter-hooks
make_resolv_conf() {
      echo "doing nothing to resolv.conf"
}
See dhclient-script(8) for details.

Need more help on this topic? Click here
This article has 5 comments
Show me similar articles