Bending resolv.conf to your will on FreeBSD

Restarted my FreeBSD machine’s network interfaces today and lost all my IPv4 DNS server mappings in /etc/resolv.conf, leading to the usual chaos. What happened and how I fixed it below.

There are days that I look over at my trusty FreeBSD file server and swear I’m going to just install Fedora 22 Server over it, converting the data drives to XFS.

But not today.

Last night I was messing around with the IPv6 configuration on the home router, and was able to see my Linux workstation get a real IPv6 address. So this morning I decided to restart the interfaces on the file server to see if it was also able to get an IPv6 address.

It did. But /etc/resolv.conf was overwritten by resolvconf (I know it was resolvconf because of the tell-tale “Generated by resolvconf” line at the top of the file), which wiped out the IPv4 nameserver directives I’d added when the box was stood up.

After Googling around awhile I found this article on one of the blogs at PaaS provider Pivotal.

Basically the answer was to create a resolvconf.conf file to force the prepending of my static name server addresses.

The man page for resolvconf.conf was, as expected, quite thorough but didn’t provide any examples of how multiple name servers should be listed using the name_servers directive.

I guessed and used spaces instead of commas or multiple directives. Turned out I was right.

# Prepend to /etc/resolv.conf
name_servers="172.16.6.1 208.67.222.222 208.67.222.220"

Running “resolvconf -u” as root resulted in my /etc/resolv.conf being updated.

I then did a “service netif restart” to recycle networking and confirm that everything would survive a reboot.

This entry was posted in System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).