Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

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?

share|improve this question

migrated from serverfault.com Jun 22 '12 at 5:35

This question came from our site for professional system and network administrators.

    
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: 192.168.100.1. 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
add comment

1 Answer 1

up vote 0 down vote accepted

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 127.0.0.1 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 127.0.0.1 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. 127.0.0.1).

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

share|improve this answer
    
(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 127.0.0.1" 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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