Ubuntu DNS Server ================= This article is part of a series on setting up an Ubuntu Network Server. Below are the other sections of the article. * [[Ubuntu Network Server]] * **Ubuntu DNS Server** * [[Ubuntu DHCP Server]] * [[Ubuntu Firewall and Router]] * [[Ubuntu File Server]] --- First, run the following to install the software for the DNS server. sudo apt-get install bind9 Edit the file `/etc/bind/named.conf.local`. Remove all of the contents and add the following: zone "shortround.net" { type master; file "/etc/bind/zones/shortround.net"; }; zone "100.168.192.in-addr.arpa" { type master; file "/etc/bind/zones/100.168.192.in-addr.arpa"; }; Make sure you substitute `shortround.net` with your domain name and also substitute `100.168.192` with your subnet. Notice, the subnet is ordered backwards from they way you are probably used to. Next, edit the `/etc/bind/named.conf.options` file. Uncomment the `forwarders` section and make it look like mine below. The forwarders are the DNS servers to query when our DNS server does not know how to resolve an address. I used [OpenDNS][opendns] for my servers. forwarders { 208.67.222.222; 208.67.220.220; }; Lastly, we need to create our zone files. The first file is used to turn a domain name into an IP address. Edit the file `/etc/bind/zones/shortround.net` and add the following: $TTL 1D @ IN SOA kiev root ( 45; 1D; 6H; 40D; 1D); NS kiev biggles A 192.168.100.20 giap A 192.168.100.21 gimli A 192.168.100.22 mail CNAME ghs.google.com. kiev A 192.168.100.1 squirt A 192.168.100.23 www A 8.12.37.105 Make sure to substitue any instance of `kiev` to the hostname of your server. Note that this DNS server handles all of the requests for your domain. If it can't find an address for the domain, it just stops there. This is a problem if you use the same domain name for your internal network as well as your web hosting. In the above file, I have to explicitly point the `www` domain to my hosting provider. I also use [Google Apps][googleapps] for my email hosting, so I have to make a pointer to Google for their website to work correctly from my network. The other zone file is `/etc/bind/zones/100.168.192.in-addr.arpa`. It is responsible for mapping IP addresses to domain names. Edit the file and add the following: $TTL 1D @ IN SOA kiev root ( 45; 1D; 6H; 40D; 1D); NS kiev.shortround.net. 1 PTR kiev.shortround.net. 20 PTR biggles.shortround.net. 21 PTR giap.shortround.net. 22 PTR gimli.shortround.net. 23 PTR squirt.shortround.net. Again, make sure to substitute any instance of `kiev` to the hostname of your server. We're now ready to test it out. First, restart the `bind` service. sudo invoke-rc.d bind9 restart There is a problem, though. Since our external interface is set dynamically, even if we tell our server to use its own domain name server, those settings will be lost the next time the interface is configured. To fix this, we need to modify the way the system handles its DHCP requests. Edit the `/etc/dhcp3/dhclient.conf` file and modify it as below. supersede domain-name "shortround.net"; prepend domain-name-servers 127.0.0.1; request subnet-mask, broadcast-address, time-offset, routers, \# domain-name, domain-name-servers, host-name, netbios-name-servers, netbios-scope; As always, you will have to modify this to fit your needs. What we've done is: 1. We forced the DHCP client to always use the "shortround.net" domain instead of the supplied one. 2. We forced the DHCP client to use our DNS server first. 3. We commented out the line that would normally give us the above settings that we forced. Now restart your networking. sudo invoke-rc.d networking restart You should now be able to resolve internet addresses as well as local computer addresses. ### One Last Note ### It's best to keep your zone files cleaned up. Notice in the first file, all of the hosts are listed in alphabetical order. Also notice that the second file has all of the hosts listed in numeric order. Keep your records this way will greatly simplify an modifications that need done. [opendns]: http://www.opendns.com "Providing A Safer And Faster Internet" [googleapps]: http://www.google.com/a "Google Apps"