Specifying a DNS server under Gentoo linux
I realised this afternoon that trackback pings from this server weren't reaching their targets. A short investigation showed that I couldn't resolve domain names. For name resolution to work, you need to have a "nameserver" directive in /etc/resolv.conf , but there wasn't one there. I remembered that I'd solved the same problem a few months ago by adding such a directive. Obviously I hadn't been thorough enough at the time if it was now broken again.
The obvious candidate to blame was rebooting the system. I'd rebooted for some reason a few weeks ago; presumably it had been broken since then. This was indeed the case as it turned out. On a Gentoo system the /etc/resolv.conf file is created by the init scripts. These init scripts use data from /etc/conf.d/net. The problem I had was that I didn't know the correct syntax for a directive in this file which would cause resolv.conf to get a nameserver directive.
After much digging, it turned out that:
- There is no documentation
- There is a file called /etc/conf.d/net.example which contains sufficient detail to allow you to fix the problem
If you add something like this to /etc/conf.d/net :
dns_servers=( "192.168.0.3" )
you'll end up in your /etc/resolv.conf with a line that looks like this:
nameserver 192.168.0.3
Hope this helps