Before configuring DNS server first know a little of it. DNS is Domain Naming Service which resolves Name to IP and IP to Name because it's difficult to remember IP address of every site every time. So DNS server resolves IP addresses to website name for us. Let's how to configure it.
[root@dns ~]# yum install bind -y
Now edit /etc/named.conf and named.rfc1912.zones file.
[root@dns ~]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.85.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 { any; };
recursion yes;
options {
listen-on port 53 { 192.168.85.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 { any; };
recursion yes;
- 192.168.85.2 is server ip where you are installing dns server.
- allow -query to any
[root@dns ~]# vim /etc/named.rfc1912.zones
zone "localhost.localdomai" IN {
type master;
file "named.localhost";
allow-update { none; };
##############################
zone "1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
zone "localhost.localdomai" IN {
type master;
file "named.localhost";
allow-update { none; };
##############################
zone "1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
[root@dns ~]# vim /etc/named.rfc1912.zones
zone "gil.com" IN {
type master;
file "gil.for";
allow-update { none; };
##############################
zone "85.168.192.in-addr.arpa" IN {
type master;
file "gil.rev";
allow-update { none; };
zone "gil.com" IN {
type master;
file "gil.for";
allow-update { none; };
##############################
zone "85.168.192.in-addr.arpa" IN {
type master;
file "gil.rev";
allow-update { none; };
- gil.com is domain name
- gil.for and gil.rev are forward and reverse lookup zones, you name as you wish
[root@dns ~]# cp /var/named/named.localhost /var/named/gil.for
[root@dns ~]# cp /var/named/named.loopback /var/named/gil.rev
[root@dns ~]# cp /var/named/named.loopback /var/named/gil.rev
Now it's time to change group for both forward and revers zones to named group.
[root@dns ~]# chgrp named /var/named/gil.for
[root@dns ~]# chgrp named /var/named/gil.rev
[root@dns ~]# chgrp named /var/named/gil.rev
Edit forward zone file /var/named/gil.for
[root@dns ~]# cp /var/named/gil.for
$TTL 1D
@ IN SOA dns.gil.com. root.gil.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS dns.gil.com.
dns IN A 192.168.85.9
$TTL 1D
@ IN SOA dns.gil.com. root.gil.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS dns.gil.com.
dns IN A 192.168.85.9
[root@dns ~]# cp /var/named/gil.rev
$TTL 1D
@ IN SOA dns.gil.com. root.dns.gil.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS dns.gil.com.
dns IN A 192.168.85.9
9 IN PTR dns
$TTL 1D
@ IN SOA dns.gil.com. root.dns.gil.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS dns.gil.com.
dns IN A 192.168.85.9
9 IN PTR dns
[root@dns ~]# named-checkconf /etc/named.conf
[root@dns ~]# named-checkconf /etc/named.rfc1912.zones
[root@dns ~]# named-checkzone gil.com /var/named/gil.for
zone gil.com/IN: loaded serial 0
OK
[root@dns ~]# named-checkzone gil.com /var/named/gil.rev
zone gil.com/IN: loaded serial 0
OK
[root@dns ~]# named-checkconf /etc/named.rfc1912.zones
[root@dns ~]# named-checkzone gil.com /var/named/gil.for
zone gil.com/IN: loaded serial 0
OK
[root@dns ~]# named-checkzone gil.com /var/named/gil.rev
zone gil.com/IN: loaded serial 0
OK
all the named files and zone files are ok no errors. Now it's time to dig.
[root@dns ~]# dig gil.com NS
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> gil.com NS
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36079
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;gil.com. IN NS
;; ANSWER SECTION:
gil.com. 86400 IN NS dns.gil.com.
;; ADDITIONAL SECTION:
dns.gil.com. 86400 IN A 192.168.85.9
;; Query time: 0 msec
;; SERVER: 192.168.85.9#53(192.168.85.9)
;; WHEN: Mon May 21 00:34:39 2012
;; MSG SIZE rcvd: 59
[root@dns ~]# dig dns.gil.com
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> dns.gil.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49083
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;dns.gil.com. IN A
;; ANSWER SECTION:
dns.gil.com. 86400 IN A 192.168.85.9
;; AUTHORITY SECTION:
gil.com. 86400 IN NS dns.gil.com.
;; Query time: 0 msec
;; SERVER: 192.168.85.9#53(192.168.85.9)
;; WHEN: Mon May 21 00:34:42 2012
;; MSG SIZE rcvd: 59
[root@dns ~]# nslookup dns.gil.com
Server: 192.168.85.9
Address: 192.168.85.9#53
Name: dns.gil.com
Address: 192.168.85.9
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> gil.com NS
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36079
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;gil.com. IN NS
;; ANSWER SECTION:
gil.com. 86400 IN NS dns.gil.com.
;; ADDITIONAL SECTION:
dns.gil.com. 86400 IN A 192.168.85.9
;; Query time: 0 msec
;; SERVER: 192.168.85.9#53(192.168.85.9)
;; WHEN: Mon May 21 00:34:39 2012
;; MSG SIZE rcvd: 59
[root@dns ~]# dig dns.gil.com
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> dns.gil.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49083
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;dns.gil.com. IN A
;; ANSWER SECTION:
dns.gil.com. 86400 IN A 192.168.85.9
;; AUTHORITY SECTION:
gil.com. 86400 IN NS dns.gil.com.
;; Query time: 0 msec
;; SERVER: 192.168.85.9#53(192.168.85.9)
;; WHEN: Mon May 21 00:34:42 2012
;; MSG SIZE rcvd: 59
[root@dns ~]# nslookup dns.gil.com
Server: 192.168.85.9
Address: 192.168.85.9#53
Name: dns.gil.com
Address: 192.168.85.9
2 Comments
Thanks for the tutorial. But there is something wrong with
ReplyDeleteediting for gil.for and gil.rev...
The code blocks both start with "cp /var/named/gil.for"
I assume one is "vi /var/named/gil.for", and the other
"vi /var/named/gil.rev".
Cheers,
-Chris
hi chris, you are right ... i mostly write posts after office, usually after 1 am, i was might be tired and mistakenly wrote gil.for for both zones, thanks for helping me correct it,
ReplyDeletegil.