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.
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 188.8.131.52 184.108.40.206"
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.