DNS Server Installation: Scenario
DNS Server Installation: Scenario
DNS Server Installation: Scenario
Scenario
For the purpose of this tutorial, I will be using three nodes. One will be acting as
Master DNS server, the second system will be acting as Secondary DNS, and
the third will be our DNS client. Here are my three systems details.
Hostname : masterdns.unixmen.local
IP Address : 192.168.1.101/24
Hostname : secondarydns.unixmen.local
IP Address : 192.168.1.102/24
Client Details:
Hostname : client.unixmen.local
IP Address : 192.168.1.103/24
Setup Primary (Master) DNS Server
Install bind9 packages on your server.
vi /etc/named.conf
Add the lines as shown in bold:
//
// named.conf
//
//
//
options {
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";
/*
recursion.
*/
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
zone "unixmen.local" IN {
type master;
file "forward.unixmen";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "reverse.unixmen";
allow-update { none; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
vi /var/named/forward.unixmen
Add the following lines:
$TTL 86400
2011071001 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
@ IN NS masterdns.unixmen.local.
@ IN NS secondarydns.unixmen.local.
@ IN A 192.168.1.101
@ IN A 192.168.1.102
@ IN A 192.168.1.103
masterdns IN A 192.168.1.101
secondarydns IN A 192.168.1.102
client IN A 192.168.1.103
vi /var/named/reverse.unixmen
Add the following lines:
$TTL 86400
2011071001 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
@ IN NS masterdns.unixmen.local.
@ IN NS secondarydns.unixmen.local.
@ IN PTR unixmen.local.
masterdns IN A 192.168.1.101
secondarydns IN A 192.168.1.102
client IN A 192.168.1.103
4. Firewall Configuration
5. Restart Firewall
firewall-cmd --reload
restorecon /etc/named.conf
7. Test DNS configuration and zone files for any syntax errors
OK
Check reverse zone:
OK
Add the DNS Server details in your network interface config file.
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="enp0s3"
UUID="5d0428b3-6af2-4f6b-9fe3-4250cd839efa"
ONBOOT="yes"
HWADDR="08:00:27:19:68:73"
IPADDR0="192.168.1.101"
PREFIX0="24"
GATEWAY0="192.168.1.1"
DNS="192.168.1.101"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
Edit file /etc/resolv.conf,
vi /etc/resolv.conf
Add the name server ip address:
nameserver 192.168.1.101
Save and close the file.
;; OPT PSEUDOSECTION:
;; QUESTION SECTION:
;masterdns.unixmen.local. IN A
;; ANSWER SECTION:
;; AUTHORITY SECTION:
;; ADDITIONAL SECTION:
nslookup unixmen.local
Sample Output:
Server: 192.168.1.101
Address: 192.168.1.101#53
Name: unixmen.local
Address: 192.168.1.103
Name: unixmen.local
Address: 192.168.1.101
Name: unixmen.local
Address: 192.168.1.102
Now the Primary DNS server is ready to use.
vi /etc/named.conf
Make the changes as shown in bold.
//
// named.conf
//
//
//
options {
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";
.
.
zone "." IN {
type hint;
file "named.ca";
};
zone "unixmen.local" IN {
type slave;
file "slaves/unixmen.fwd";
masters { 192.168.1.101; };
};
zone "1.168.192.in-addr.arpa" IN {
type slave;
file "slaves/unixmen.rev";
masters { 192.168.1.101; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
ls /var/named/slaves/
Sample Output:
unixmen.fwd unixmen.rev
Add the DNS Server details in your network interface config file.
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="enp0s3"
UUID="5d0428b3-6af2-4f6b-9fe3-4250cd839efa"
ONBOOT="yes"
HWADDR="08:00:27:19:68:73"
IPADDR0="192.168.1.102"
PREFIX0="24"
GATEWAY0="192.168.1.1"
DNS1="192.168.1.101"
DNS2="192.168.1.102"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
Edit file /etc/resolv.conf,
vi /etc/resolv.conf
Add the name server ip address:
nameserver 192.168.1.101
nameserver 192.168.1.102
Save and close the file.
4. Firewall Configuration
5. Restart Firewall
firewall-cmd --reload
restorecon /etc/named.conf
;; Got answer:
;; OPT PSEUDOSECTION:
;; QUESTION SECTION:
;masterdns.unixmen.local. IN A
;; ANSWER SECTION:
;; ADDITIONAL SECTION:
;; SERVER: 192.168.1.102#53(192.168.1.102)
dig secondarydns.unixmen.local
Sample Output:
;; Got answer:
;; QUESTION SECTION:
;secondarydns.unixmen.local. IN A
;; ANSWER SECTION:
;; AUTHORITY SECTION:
;; ADDITIONAL SECTION:
;; SERVER: 192.168.1.102#53(192.168.1.102)
nslookup unixmen.local
Sample Output:
Server: 192.168.1.102
Address: 192.168.1.102#53
Name: unixmen.local
Address: 192.168.1.101
Name: unixmen.local
Address: 192.168.1.103
Name: unixmen.local
Address: 192.168.1.102
vi /etc/resolv.conf
# Generated by NetworkManager
search unixmen.local
nameserver 192.168.1.101
nameserver 192.168.1.102
Restart network service or reboot the system.
Now, you can test the DNS server using any one of the following commands:
dig masterdns.unixmen.local
dig secondarydns.unixmen.local
dig client.unixmen.local
nslookup unixmen.local
That’s all about now. The primary and secondary DNS servers are ready to use.