The following guide will help you setup your very own fully functional local DNS Server for your Linux Operating Systems.
Once installed, we configure the DNS Server. To do this, we need to edit a configuration file with some parameters:
// // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // options { listen-on port 53 { 127.0.0.1; 192.168.50.128;}; ### Provide your Master DNS IP ### listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { localhost; 192.168.50.0/24;}; ### IP Address Range ### allow-transfer{ localhost; 192.168.50.129;}; ### Slave DNS IP Address ### recursion yes; dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; zone "." IN { type hint; file "named.ca"; }; ### Forward Lookup Zone ###
zone"cloud.com" IN { type master; file "forward.cloud"; allow-update { none; }; };
### Reverse Lookup Zone ###
zone"50.168.192.in-addr.arpa" IN { type master; file "reverse.cloud"; allow-update { none; }; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key";
# vi /var/named/forward.cloud
$TTL 86400 @ IN SOA masterdns.cloud.com. root.cloud.com. ( 2011071001 ;Serial 3600 ;Refresh 1800 ;Retry 604800 ;Expire 86400 ;Minimum TTL ) @ IN NS masterdns.cloud.com. @ IN NS slavedns.cloud.com. @ IN A 192.168.50.128
@ IN A 192.168.50.129 @ IN A 192.168.50.130 masterdns IN A 192.168.50.128 slavedns IN A 192.168.50.129 client IN A 192.168.50.130
# vi /var/named/reverse.cloud
$TTL 86400 @ IN SOA masterdns.cloud.com. root.cloud.com. ( 2011071001 ;Serial 3600 ;Refresh 1800 ;Retry 604800 ;Expire 86400 ;Minimum TTL ) @ IN NS masterdns.cloud.com. @ IN NS slavedns.cloud.com. @ IN PTR cloud.com.
masterdns IN A 192.168.50.128 slavedns IN A 192.168.50.129 client IN A 192.168.50.130
128 IN PTR masterdns.cloud.com. 129 IN PTR slavedns.cloud.com. 130 IN PTR client.cloud.com.
# named-checkconf /etc/named.conf
# named-checkzone unixmen.local /var/named/forward.cloud
# named-checkzone unixmen.local /var/named/reverse.cloud
You can test your DNS server by running the following command.
You should receive the output with a "NOERROR" status as shown:
Once our Master DNS is set up, setting up a secondary or slave DNS Server is optional, but its always a good practice to have one in place. Installing a Slave DNS server is no different for that of the Master, just a few configurations differ.
To get started, first install bind on the slave DNS Server machine:
Make ONLY the changes that are highlighted below:
// // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // options { listen-on port 53 { 127.0.0.1; 192.168.50.129;}; ### Provide your Slave DNS IP ### listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { localhost; 192.168.50.0/24;}; ### IP Address Range ### recursion yes; dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; zone "." IN { type hint; file "named.ca"; }; ### Forward Lookup Zone ###
zone"cloud.com" IN { type slave; file "slaves/cloud.fwd";
masters {192.168.50.128;}; };
### Reverse Lookup Zone ###
zone"50.168.192.in-addr.arpa" IN { type slave; file "slaves/cloud.rev"; masters {192.168.50.128;}; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key";
Once done, save the file and exit the editor.
You can see that once the service is started, the Forward and Reverse lookup zone files are automatically copied form the Master DNS to /var/named/slaves folder in the Slave DNS Server.
You can test your DNS server by running the following command.
You should receive the output with a "NOERROR" status as shown:
Once our Master DNS and Slave DNS is set up, we can now configure our Linux Clients against this Domain:
In all your ‘Client’ machines, simply add the following entries in the following file:
search 192.168.50.129
Save the file and exit the editor. You should now be able to see your ‘Client’ Machine’s FQDN as well as shown below:
NOTE: You will have to manually add each Client in your Master DNS forward and reverse files. This will help in providing a FQDN to your clients.
Thats all for now.. hope this tutorial guides you to set up your DNS successfully..