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
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;
        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
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 *