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 ]
Article Feedback - Stripping ^M from your files
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 resolv.conf being modified
Author: mygoggie 
Date:   20-01-07 11:45

Hi there

This article is fairly old, but my two pence could be worth the while to somebody out there.

Yes, you are quite correct in that DHCP client overwrites the file /etc/resolv.conf.

The question that must be asked is where does the DHCP client get the info that it writes into /etc/resolv.conf? Well, the answer can only be, from the DHCP server!

So with all due respect your solution, it is like taking some medicine for a headache. Why not fix the root of the problem that causes the headache and leave the medicine alone? :-)

Your DHCP server is incorrectly configured for your requirements.

So let's fix it ...

YOU WANT:
domain www.example.org
nameserver 10.0.0.1 # my min-dns server
nameserver 11.22.33.44
nameserver 11.22.33.45

So let us open up the DHCP server's configuration file (BTW I use the standard FreeBSD isc-dhcpd installed via ports) ...

These are the steps you need to go through:

1. Log into the DHCP server via SSH or physically,

2. su to get root access and log in,

3. Switch to the directory where "dhcpd.config" is located. For FreeBSD 5.x and above this is in /usr/local/etc

dhcpserver# cd /usr/local/etc

4. Open the file "dhcpd.conf" with "vi" or "ee" or your favourite editor

5. Find the section that contains your subnet settings. In your case it will read something like

subnet 10.0.0.0 netmask 255.255.255.0 {

6. Now all we need to do is add the domain name and the name servers you want. This is done with the "options" statement

7. In your case you will add to the section the following:

subnet 10.0.0.0 netmask 255.255.255.0 {
domain-name "www.example.org";
domain-name-servers 10.0.1.4;
domain-name-servers 11.22.33.44;
domain-name-servers 11.22.33.45;
..... rest of existing detail
}

8. Save and exit

9. Now we need to restart the DHCP server. First let us stop it gracefully. Enter at the prompt:

dhcpserver# ./rc.d/isc-dhcpd.sh stop

wait for the server to stop. A few messages will appear ...

Now start it again by entering at the prompt the following:

dhcpserver# ./rc.d/isc-dhcpd.sh start

and wait for it to start.

10. Now go to your client machine. You might have been sitting at it all the while! ;-)

11. Log in at your client machine

12. Switch to super user with "su" command and log in

13. OK now we need to renew our DHCP session. First you need to know what your interface name is. Let's find that out by a simple ifconfig command. Enter at the command prompt:

myclient# ifconfig

Make a note (or mental one) of the NIC's name - let say we find it is "fxp0"

So now to renew the FreeBSD DHCP session. Enter at the command prompt:

myclient# dhclient fxp0

and you will see a message appearing that give the new DHCP session details.

14. Check if your detail is now as you want it by entering:

myclient# more /etc/resolv.conf

You should (if all went well) see:

search "www.example.org"
nameserver 10.0.0.10
nameserver 11.22.33.44
nameserver 11.22.33.45

Well, I trust this helps somebody out here!

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org