Setting DNS in FreeBSD 10

Hi,
I connect to the internet using a DSL router. Network configuration is done using DHCP. What I want FreeBSD to do is obtain the IP address, subset mask, default gateway using DHCP but not the DNS.

I want to use OpenDNS. When I change the nameserver addresses in resolv.conf it works but once I reboot it reverts back to 192.168.1.1.

How to make the changes permanent?
 
Hi,

Create a file named dhclient-enter-hooks in /etc, then append the following code to the file:

Code:
add_new_resolv_conf() {
	return 0
}

Save the file and either restart network services or reboot. This will prevent dhclient() from changing the resolv.conf file. Keep in mind if the IP address of your nameserver/s change you will have to manually update them in resolv.conf each time after doing this. There may be a different/better way of doing this but I have done it since I started using FreeBSD with no ill effects.
 
Another way I use on my host with a local BIND instance.

In /etc/dhclient.conf.
Code:
interface "em3"
{
  supersede domain-name-servers 127.0.0.1;
}

See dhclient.conf() for more information.
 
Back
Top