DHCP and resolv.conf

Network Switch with Cables

DHCP on FreeBSD updates your DNS information in /etc/resolv.conf.  This works great for workstation and other systems that only have one interface but what about systems that are connected to multiple networks.  You may not want it to update your /etc/resolv.conf or just update part of it.

 

There is a way to fix this.  /etc/dhclient.conf to the rescue!  You can use /etc/dhclient.conf to tell your dhcp client what information your want from the remote dhcp server or even over ride some of the responces.  For example:

 

Here is my /etc/resolv.conf for a system I have:

# Generated by resolvconf
search ed.shawcable.net
nameserver 64.59.184.15
nameserver 64.59.190.245
 
This is not what I want.  I would like to it point to my own name server and also  search my domains. I have two interfaces in this server and run dhcpclient on interface em1.  I add the following definition into /etc/dhclient.conf:
 
#
interface “em1” {
        supersede domain-name-servers 172.31.15.250;
        supersede domain-name “bohica.net int.bohica.net”;
}
 
and now this is what my /etc/resolv.conf look like:
 
# Generated by resolvconf
search bohica.net int.bohica.net
nameserver 172.31.15.250
 
as you can see this problem is solve.  There is a lot more you can use /etc/dhclient.conf for.  You should check it out or read the man page at ‘man 5 dhclient.conf’
 
 

Leave a Comment

Your email address will not be published. Required fields are marked *