After configure master record now here we are Create Reverse zone file for convert ip Address to name. For hosting PTR record in DNS we need to create Reverse zone file entry in /etc/named.conf file. same like below
zone "0.168.192.in-addr.arpa" IN {
type master;
file "192.168.0.zone";
};
Edit reverse zone entry in /etc/named.conf
[root@master ~]# vim /etc/named.conf
[root@master ~]# cat /etc/named.conf
//
// 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.
//
// See the BIND Administrator's Reference Manual (ARM) for details about the
// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html
options {
listen-on port 53 { 127.0.0.1; 192.168.10.2; };
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.10.0/24; };
/*
- If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable access
control to limit queries to your legitimate users. Failing to do so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;
// dnssec-enable yes;
// dnssec-validation yes;
/* Path to ISC DLV key */
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 "zmailtech.com" IN {
type master;
file "zmailtech.com.zone";
};
zone "10.168.192.in-addr.arpa" IN {
type master;
file "10.168.192.zone";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
[root@master ~]#
PTR records are used for the Reverse DNS (Domain Name System) lookup. Using the IP address you can get the associated domain/hostname. An A record should exist for every PTR record. The usage of a reverse DNS setup for a mail server is a good solution.
Now here we are hosting PTR Record in DNS service.
Create reverse zone file, we are copy named.loopback file into 10.168.192.zone file for revers zone
[root@master ~]# cat /var/named/named.loopback > /var/named/10.168.192.zone
Assigning proper permission and owenership on zmailtech.com.zone file.
[root@master ~]# ls -l /var/named
total 24
-rw-r--r--. 1 root root 168 Dec 14 16:19 10.168.192.zone
drwxrwx---. 2 named named 49 Dec 14 13:43 data
drwxrwx---. 2 named named 60 Dec 14 16:11 dynamic
-rw-r-----. 1 root named 2281 May 22 2017 named.ca
-rw-r-----. 1 root named 152 Dec 15 2009 named.empty
-rw-r-----. 1 root named 152 Jun 21 2007 named.localhost
-rw-r-----. 1 root named 168 Dec 15 2009 named.loopback
drwxrwx---. 2 named named 6 Aug 4 13:43 slaves
-rw-r--r--. 1 root named 470 Dec 14 13:44 zmailtech.com.zone
[root@master ~]#
Change 10.168.192.zone reverse zone file group owner to named group owner
[root@master ~]# chgrp named /var/named/10.168.192.zone
[root@master ~]# ls -l /var/named
total 24
-rw-r--r--. 1 root named 168 Dec 14 16:19 10.168.192.zone
drwxrwx---. 2 named named 49 Dec 14 13:43 data
drwxrwx---. 2 named named 60 Dec 14 16:11 dynamic
-rw-r-----. 1 root named 2281 May 22 2017 named.ca
-rw-r-----. 1 root named 152 Dec 15 2009 named.empty
-rw-r-----. 1 root named 152 Jun 21 2007 named.localhost
-rw-r-----. 1 root named 168 Dec 15 2009 named.loopback
drwxrwx---. 2 named named 6 Aug 4 13:43 slaves
-rw-r--r--. 1 root named 470 Dec 14 13:44 zmailtech.com.zone
[root@master ~]#
Edit PTR record in 10.168.192.zone Revers zone
[root@master ~]# vim /var/named/10.168.192.zone
[root@master ~]# cat /var/named/10.168.192.zone
$TTL 1D
@ IN SOA ns1.zmailtech.com. admin.zmailtech.com. (
2017121501 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns1.zmailtech.com.
IN A 192.168.10.2
2 IN PTR ns1.zmailtech.com.
2 IN PTR mail.zmailtech.com.
[root@master ~]#
Need to restart bind (named) service after change in DNS Records zone file.
[root@master ~]# systemctl restart named
Lets check PTR record with dig -x command.
[root@master ~]# dig -x 192.168.10.2
; <<>> DiG 9.9.4-RedHat-9.9.4-50.el7 <<>> -x 192.168.10.2
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28756
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;2.10.168.192.in-addr.arpa. IN PTR
;; ANSWER SECTION:
2.10.168.192.in-addr.arpa. 86400 IN PTR ns1.zmailtech.com.
2.10.168.192.in-addr.arpa. 86400 IN PTR mail.zmailtech.com.
;; AUTHORITY SECTION:
10.168.192.in-addr.arpa. 86400 IN NS ns1.zmailtech.com.
;; ADDITIONAL SECTION:
ns1.zmailtech.com. 86400 IN A 192.168.10.2
;; Query time: 1 msec
;; SERVER: 192.168.10.2#53(192.168.10.2)
;; WHEN: Thu Dec 14 16:10:57 IST 2017
;; MSG SIZE rcvd: 134
[root@master ~]#
zone "0.168.192.in-addr.arpa" IN {
type master;
file "192.168.0.zone";
};
Edit reverse zone entry in /etc/named.conf
[root@master ~]# vim /etc/named.conf
[root@master ~]# cat /etc/named.conf
//
// 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.
//
// See the BIND Administrator's Reference Manual (ARM) for details about the
// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html
options {
listen-on port 53 { 127.0.0.1; 192.168.10.2; };
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.10.0/24; };
/*
- If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable access
control to limit queries to your legitimate users. Failing to do so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;
// dnssec-enable yes;
// dnssec-validation yes;
/* Path to ISC DLV key */
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 "zmailtech.com" IN {
type master;
file "zmailtech.com.zone";
};
zone "10.168.192.in-addr.arpa" IN {
type master;
file "10.168.192.zone";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
[root@master ~]#
PTR records are used for the Reverse DNS (Domain Name System) lookup. Using the IP address you can get the associated domain/hostname. An A record should exist for every PTR record. The usage of a reverse DNS setup for a mail server is a good solution.
Now here we are hosting PTR Record in DNS service.
Create reverse zone file, we are copy named.loopback file into 10.168.192.zone file for revers zone
[root@master ~]# cat /var/named/named.loopback > /var/named/10.168.192.zone
Assigning proper permission and owenership on zmailtech.com.zone file.
[root@master ~]# ls -l /var/named
total 24
-rw-r--r--. 1 root root 168 Dec 14 16:19 10.168.192.zone
drwxrwx---. 2 named named 49 Dec 14 13:43 data
drwxrwx---. 2 named named 60 Dec 14 16:11 dynamic
-rw-r-----. 1 root named 2281 May 22 2017 named.ca
-rw-r-----. 1 root named 152 Dec 15 2009 named.empty
-rw-r-----. 1 root named 152 Jun 21 2007 named.localhost
-rw-r-----. 1 root named 168 Dec 15 2009 named.loopback
drwxrwx---. 2 named named 6 Aug 4 13:43 slaves
-rw-r--r--. 1 root named 470 Dec 14 13:44 zmailtech.com.zone
[root@master ~]#
Change 10.168.192.zone reverse zone file group owner to named group owner
[root@master ~]# chgrp named /var/named/10.168.192.zone
[root@master ~]# ls -l /var/named
total 24
-rw-r--r--. 1 root named 168 Dec 14 16:19 10.168.192.zone
drwxrwx---. 2 named named 49 Dec 14 13:43 data
drwxrwx---. 2 named named 60 Dec 14 16:11 dynamic
-rw-r-----. 1 root named 2281 May 22 2017 named.ca
-rw-r-----. 1 root named 152 Dec 15 2009 named.empty
-rw-r-----. 1 root named 152 Jun 21 2007 named.localhost
-rw-r-----. 1 root named 168 Dec 15 2009 named.loopback
drwxrwx---. 2 named named 6 Aug 4 13:43 slaves
-rw-r--r--. 1 root named 470 Dec 14 13:44 zmailtech.com.zone
[root@master ~]#
Edit PTR record in 10.168.192.zone Revers zone
[root@master ~]# vim /var/named/10.168.192.zone
[root@master ~]# cat /var/named/10.168.192.zone
$TTL 1D
@ IN SOA ns1.zmailtech.com. admin.zmailtech.com. (
2017121501 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns1.zmailtech.com.
IN A 192.168.10.2
2 IN PTR ns1.zmailtech.com.
2 IN PTR mail.zmailtech.com.
[root@master ~]#
Need to restart bind (named) service after change in DNS Records zone file.
[root@master ~]# systemctl restart named
Lets check PTR record with dig -x command.
[root@master ~]# dig -x 192.168.10.2
; <<>> DiG 9.9.4-RedHat-9.9.4-50.el7 <<>> -x 192.168.10.2
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28756
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;2.10.168.192.in-addr.arpa. IN PTR
;; ANSWER SECTION:
2.10.168.192.in-addr.arpa. 86400 IN PTR ns1.zmailtech.com.
2.10.168.192.in-addr.arpa. 86400 IN PTR mail.zmailtech.com.
;; AUTHORITY SECTION:
10.168.192.in-addr.arpa. 86400 IN NS ns1.zmailtech.com.
;; ADDITIONAL SECTION:
ns1.zmailtech.com. 86400 IN A 192.168.10.2
;; Query time: 1 msec
;; SERVER: 192.168.10.2#53(192.168.10.2)
;; WHEN: Thu Dec 14 16:10:57 IST 2017
;; MSG SIZE rcvd: 134
[root@master ~]#