I've done some prerequisite reading on DNS and BIND via O'Reilly's book. My goal is to have a local DNS server (i.e. seldon.foundation) that resolves local names (i.e. *.foundation) but forwards the rest to OpenDNS or Google.

  • My zone file :
$TTL 3h
foundation. IN SOA seldon.foundation. avery.foundation.com. (
 1        ; Serial
 3h       ; Refresh after 3 hours
 1h       ; Retry after 1 hour
 1w       ; Expire after 1 week
 1h       ; Negative caching TTL of 1 hour

; Name servers
foundation.  IN NS  seldon.foundation.

; Addresses for the canonical names
localhost.foundation.      IN A
seldon.foundation.         IN A

; Aliases
dns.foundation.       IN CNAME seldon.foundation.
  • My named.conf.local:
zone "foundation" in {
        type master;
        file "db.foundation";

zone "1.168.192.in-addr.arpa" in {
        type master;
        file "db.192.168.1";

After I restart bind with: sudo service bind9 restart I know it loads the files (and loads them without error) because I check syslog. But when I do a dig seldon.foundation I don't get the expected result.

resolv.conf has two IP addresses but there's a note in the file saying not to edit the file by hand. What do I do now?

  • Is your named.conf.local still being included from your named.conf? – Shane Madden Jun 22 '12 at 3:07
  • Yes. It's the stock Ubuntu 12.04 install which does a include "/etc/bind/named.conf.local"; – Avery Chan Jun 22 '12 at 3:14
  • What addresses are in the resolv.conf? Does it work correctly when you try dig @localhost seldon.foundation? – Shane Madden Jun 22 '12 at 4:31
  • So the addresses in resolv.conf are the local router's address and that's it: It /does/ work correctly when I do a dig @localhost seldon.foundation. I know that my machine is getting the IP addresses in resolv.conf from the router because the other two IP addresses were the DNS servers from Google and OpenDNS. – Avery Chan Jun 22 '12 at 5:26

Part of the challenge of answering this question comes out of knowing what documentation to look at. In particular, Ubuntu 12.04 (I'm using the server distribution), works a little different than the documentation for named/bind might suggest. I spent a lot of time tweaking things that didn't need to be tweaked. Without further ado:

  1. Read up on DNS & BIND first. The first couple chapters of O'Reilley's 'DNS and BIND' book are excellent. A lot of the examples on the web use the abbreviated syntax which isn't as clear (IMO) as the longer syntax.
  2. Edit /etc/bind/named.conf.local. If you take a look at my pastebin'd files, you can see how I set up my own network. Again, if you don't understand what's going on there, read up more on DNS & BIND (or ask some simpler questions here or on serverfault.com that specifically address the issue you don't understand).
  3. Place your zone files in /var/cache/bind. If you look in /etc/bind/named.conf.options, you'll see that the directory to look for the zone files is in /var/cache/bind. Nevermind that that this directory (/etc/bind/) is littered with zone files. I don't understand why some zonefiles are picked up here but any user defined ones must be in /var/cache/bind. I leave that to the wizards with more EXP than me to explain.
  4. Add appropriate DNS forwarding addresses to named.conf.options. This will allow you to get reasonable name resolution for domains that your subnetwork doesn't handle. You can see where to add this (if you're on Ubuntu) by uncommenting the lines that being with 'forwarders'. Add the IP addresses of the DNS machines you want to use. Make sure you delimit them with a semi-colon.
  5. Add to resolv.conf. This is tricky because if you open /etc/resolv.conf you'll see a note telling you not to edit this file. What you want to do is follow the advice from here: Stéphane's introduction to DNS on 12.04. Edit the file /etc/resolvconf/resolv.conf.d/head and add your localhost by entering nameserver to the end of this file, followed by a newline.
  6. Re-update resolv.conf with resolvconf -u. This commands resets resolv.conf with the new configuration you've specified in resolv.conf.d/head.
  7. Re-test with dig seldon.foundation or whatever is appropriate for your network. You should the server at the bottom show the loopback address (i.e.

Thanks @Shane Madden for giving me enough clues to move forward.

  • (1) Ideally bind9 would be integrated with resolvconf sufficiently that it would update its forwarders list from resolvconf's database. This has already been requested: bugs.debian.org/cgi-bin/bugreport.cgi?bug=483098#29. (2) You don't need to add "nameserver" to /etc/resolvconf/resolv.conf.d/head. You can simply set 'RESOLVCONF=yes' in the file /etc/default/bind9 (which you may have to create); then bind9's initscript will register the loopback address with resolvconf when named starts and de-register the address when named stops. – jdthood Oct 29 '12 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.