Difference between revisions of "Configure DNS"

From Organic Design wiki
m (moved Dynamic DNS to Configure DNS: more general now)
m (Local DNS Server)
Line 25: Line 25:
 
forwarders {
 
forwarders {
 
         58.28.4.2;
 
         58.28.4.2;
 +
        58.28.6.2;
 
};
 
};
 
</pre>}}
 
</pre>}}

Revision as of 05:04, 20 May 2009

Procedure.svg Configure DNS
Organic Design procedure

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 namecheap.com 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 "http://dynamicdns.park-your-domain.com/update?host=SUB&domain=DOMAIN&password=PASS"


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

Local DNS Server

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.

Install Bind9 with apt-get install bind9, then edit /etc/bind9/named.conf.options and set the forwarders to your ISP's domain name server, e.g.

forwarders {
        58.28.4.2;
        58.28.6.2;
};


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

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

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


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

$TTL	1D
@	IN SOA ns1.foo.co.nz. root.foo.co.nz. (
                      200905081         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL

		NS      ns1
		MX	10 mail.foo.co.nz.
ns1	IN	A	192.168.1.1
www	IN	A	202.174.108.130
wiki	IN	A	192.168.1.1
mail	IN	A	192.168.1.1


And the reverse lookup file also in /var/cache/bind:

@ IN SOA foo.co.nz. root.foo.co.nz. (
                       20090508		; Serial
                         604800		; Refresh
                          86400		; Retry
                        2419200		; Expire
                         604800 )	; Default TTL

	IN	NS	ns1.foo.co.nz.
1	IN	PTR	foo.co.nz.

See also

  • DynamicDNS.pl - the script we used to use to update DNS records only when router's external IP changes