It may come as a surprise to quite a few guys that know me, but I use FreeNAS as my main file server. I used version 0.6 for quite a while but I switched to 0.7 few weeks ago.
At one point in time I noticed that one of my scripts is not working anymore. That script checked my external IP address and displayed it on character LCD. I could not say when exactly it stopped working since I didn’t checked it for a while.
Little bit of digging discovered that I had problems with host name resolving:
host example.dyndns.org 0.0.0.0 connect: Address family not supported by protocol family 0.0.0.0 connect: Address family not supported by protocol family example.dyndns.org A record not found, try again
Then I remembered. Few days after upgrading server to new FreeNAS edition, I also changed configuration from DHCP to static IP. That meant that DNS servers were not set anymore. All I needed to do is to manually set DNS addresses and script would be working once more.
Only problem – no manual setting of DNS is available. Since I know a thing-or-two about command line interface, I went to add missing entries to
/etc/resolv.conf from there. Unfortunately, that file gets overwritten after every reboot.
Since I didn’t want to depend on power grid to keep my server alive, I devised a cunning plan. If you go into System -> Advanced menu, there is option to set commands to be executed after every reboot. I just added new postinit command:
echo "nameserver 22.214.171.124" >> /etc/resolv.conf
That line just appended DNS server definition to file. Once that line is there, all DNS resolving works once more.
P.S. After all this effort, I found place where DNS can be setup in more user friendly manner. To my surprise it is under System -> General menu.