Prerequisites for our configuration:
- 2 servers, one for primary DNS, the other for secondary DNS
- server 1 - primary DNS
- static IP 192.168.1.8
- gateway 192.168.1.1
- DNS 192.168.1.8, 192.168.1.3
- hostname
ns
in file/etc/hostname
- entry
127.0.1.1 ns
in/etc/hosts
- server 2 - secondary DNS
- static IP 192.168.1.3
- gateway 192.168.1.1
- DNS 192.168.1.8, 192.168.1.3
- hostname
ns2
in file/etc/hostname
- entry
127.0.1.1 ns2
in/etc/hosts
Install bind9 DNS server software:
sudo apt-get install bind9 bind9utils bind9-docVerify content of
named.conf
. This is the primary configuration file for the bind DNS Server. It usually contains only includes of other configuration files.cat /etc/bind/named.confDefault content:
include "/etc/bind/named.conf.options";include "/etc/bind/named.conf.local";include "/etc/bind/named.conf.default-zones";
Edit
named.conf.options
:sudo nano /etc/bind/named.conf.optionsThe example of the file. The
acl
clause allows fine-grained control over what hosts or users may perform what operations on the name server. Within thegoodclients
block, list the IP addresses or networks that should be allowed to use this DNS server. Blockforwarders
contains the IP addresses of the recursive name servers that we want to forward requests to. We will use Google's public DNS servers (8.8.8.8 and 8.8.4.4).acl goodclients {192.168.1.0/24;localhost;localnets;};options {directory "/var/cache/bind";recursion yes;allow-query { goodclients; };forwarders {0.0.0.0;8.8.8.8;8.8.4.4;};forward only;dnssec-enable yes;dnssec-validation yes;auth-nxdomain no; # conform to RFC1035listen-on-v6 { any; };}Make a copy of local zone configuration template. The new file
main.mydomain.com
will hold our zone configuration.sudo cp /etc/bind/db.local /etc/bind/main.mydomain.comDefine
mydomain.com
zone innamed.conf.local
file and point to your newly created zone filemain.mydomain.com
:sudo nano /etc/bind/named.conf.localThe zone definition should look like this:
zone "mydomain.com" {type master;file "/etc/bind/main.mydomain.com";};Configure your zone definition file
main.mydomain.com
.sudo nano /etc/bind/main.mydomain.comThe following is
mydomain.com
zone configuration example.NS
entry type identifies the nameservers. Thens
,ns2
,archive
, andmirror
entries map the subdomain names to the IP addresses.$TTL
entry dictates timeout for the DNS cache (in seconds). After the timeout, the DNS entries are reloaded again.;; BIND data file for local loopback interface;$TTL 604800@ IN SOA mydomain.com. root.mydomain.com. (2 ; Serial604800 ; Refresh86400 ; Retry2419200 ; Expire604800 ) ; Negative Cache TTLIN A 192.168.1.2www IN A 192.168.1.2;@ IN NS ns.mydomain.com.@ IN NS ns2.mydomain.com.@ IN A 192.168.1.2@ IN AAAA ::1ns IN A 192.168.1.8ns2 IN A 192.168.1.3To apply the new configuration, restart the DNS server:
sudo service bind9 restart
NOTES
File /etc/nsswitch.conf
contains order of preference in using hosts file and DNS. In our scenario, we use DNS first, then the hosts file:
hosts: dns files
No comments:
Post a Comment