Configure DNS

From Organic Design
Jump to: navigation, search
Procedure.svg Configure DNS
Organic Design procedure

Local caching DNS Server

Setting up a local caching DNS server is a good idea to ensure that DNS requests return quickly (especially useful if you have sites that make requests before returning the pages). It's also essential if you're running spam assassin because the domain black-lists (DNSBL) services operate over DNS and will often block requests made from large ISP's DNS servers. The most popular DNS server is Bind9 and is set up in caching configuration by default.

First install bind9:

apt-get install bind9

Change the ISP name servers in your /etc/resolv.conf file to use the new local server instead:


Note: Don't forget to check /etc/network/interfaces and comment out any DNS servers specified there too.

Setting up local domains names

Requests under the organisation's domain name from the Internet must be forwarded to the ISP-assigned external IP address using an A-record. This may require Dynamic DNS if a static IP address arrangement has not been made with the ISP.

Requests made for the domain from within the LAN require the local server to be authoritative, but to refer all other requests to the ISP-assigned DNS servers.

The following example is for a domain called which has an internal wiki and mail-server, but an external website on the IP address and all other sub-domains (apart from wiki and mail) pointing at the external IP address This example assumes that the domain is configured correctly for resolving external requests, and focusses on the configuration of the DNS server running internally on the LAN on IP address The wiki, DNS server and mail-server are all running on the same machine.

Install Bind9 with apt-get install bind9, then edit /etc/bind/named.conf.options and set the forwarders to your ISP's domain name server, or a public name-server such as (also some easy to remember ones are and e.g.

forwarders {;;

Add the following zone configuration in /etc/bind/named.conf.local:

zone "" {
	type master;
	file "foo.db";

zone "" {
	type master;
	file "db.192";

The zone files reside in /var/cache/bind and are of the following format:

@	IN SOA (
                      200905081             ; Serial
                         604800             ; Refresh
                          86400             ; Retry
                        2419200             ; Expire
                         604800 )           ; Negative Cache TTL

		NS      ns1
		MX	10
ns1	IN	A
www	IN	A
wiki	IN	A
mail	IN	A
@	IN	A
*	IN	A
foo     IN      CNAME
  • Note: The "@" symbol means the naked domain
  • Note: CNAME's work for subdomains and * but not for @

And the reverse lookup file, /var/cache/bind/db.192:

@ IN SOA (
                      200905081		; Serial
                         604800		; Refresh
                          86400		; Retry
                        2419200		; Expire
                         604800 )	; Default TTL



  • Be sure to increase the serial number each time a zone file is edited or the changes will be ignored
  • Remember to reload the zone files after making changes with service bind9 reload.
  • Note the "1" in the last line of the reverse lookup is the last digit of the DNS server's IP address

Public DNS servers




  • 2001:4860:4860::8888
  • 2001:4860:4860::8844







Dynamic DNS

It's often useful to be able to access machines on our local LAN's from other locations. Most of the LAN's we need to access machines on do not have static IP addresses, so a Dynamic DNS solution is used to keep a domain name up to date with the current IP address.

Our .com domain host is and they provide a free dynamic DNS solution allowing simple HTTP query-string based method of updating a sub-domain. We just add a single entry to /etc/crontab which looks like this (replace SUB, DOMAIN and PASS with your specific settings):

*/10 * * * * nobody wget -q --spider ""

The subdomain will automatically be created when the first request is made if it didn't previously exist. The password is shown in the admin site in the "DynamicDNS" section for the appropriate domain.

See also