Changing the DNS nameservers in FreeBSD

Adding the nameservers to the /etc/resolv.conf file will only temporarily change the DNS nameservers. After the system is restarted, FreeBSD will default to the DNS servers obtained from the DHCP server.

To permanently alter the DNS nameservers to the ones you want to use, they need to be added to the /etc/dhclient.conf file.

$ sudo nano /etc/dhclient.conf

Add the following to the dhclient.conf file

interface "em0" {
    supersede domain-name-servers,;

Replace the interface “em0” with your default interface name, and obviously the IP address of the DNS nameservers with your own.

For more information read the man pages for dhclient and dhclient.conf.


If you disable the DHCP server in /etc/rc.conf, for example, by setting a static IP address, the supersede directive will not work. You must then edit the resolv.conf file manually and add the nameservers.