## Configuring DNS server on REDHAT 6.
Step # 1a: Configure the network Interface like this:
[root@server ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:1D:09:10:49:DC
inet addr:192.168.0.254 Bcast:192.168.0.255 Mask:255.255.255.0 ## DNS server machine Ethernet
inet6 addr: fe80::21d:9ff:fe10:49dc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:578841 errors:0 dropped:0 overruns:0 frame:0
TX packets:31217 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:59073403 (56.3 MiB) TX bytes:5895624 (5.6 MiB)
Interrupt:16
[root@server ~]#
Step # 1b: Set Host Configuration as follows:
[root@server named]# cat /etc/hosts
127.0.0.1 localhost.localdomain
::1 localhost.localdomain
192.168.0.254 server.example.com server
[root@server named]# cat /etc/resolv.conf
nameserver 192.168.0.254
search example.com
[root@server named]#
Step # 2: Install Bind.
[root@server ~]# yum install bind*
Step # 3: Edit named.conf: we need to change only three lines in this file:
[root@server ~]# vi /etc/named.conf
options {
listen-on port 53 { 192.168.0.254; }; ## Enter Your IP Here by !!
#listen-on-v6 port 53 { ::1; }; ## Comment this line
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; }; ## Allow Query to DNS from outside world
recursion yes;
.
.
. ## Keep other configuration as it is
.
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
Step # 4: We need to define our Zone file which is done in /etc/named.rfc1912.zones as follows:
[root@server named]# cat /etc/named.rfc1912.zones
zone "example.com" IN {
type master;
file "forward.zone"; ; Forward Zone will be defined in forward.zone
allow-update { none; };
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "reverse.zone"; ; Reverse Zone will be defined in reverse.zone
allow-update { none; };
};
[root@server named]#
Step # 5: Now we configure Forward Zone and Reverse Zone:
[root@server named]# cat /var/named/forward.zone
$TTL 1D
@ IN SOA server.example.com. root.server.example.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS server.example.com.
server IN A 192.168.0.254
test IN A 192.168.0.100 ; Like this we can any number of domains
[root@server named]#
[root@server named]# cat /var/named/reverse.zone
$TTL 1D
@ IN SOA server.example.com. root.example.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS server.example.com.
254 IN PTR server.example.com.
100 IN PTR test.example.com. ; Like this we can any number of domains
[root@server named]#
Step # 6: Start Bind.
[root@server named]# /etc/init.d/named start
Starting named: [ OK ]
[root@server named]#
[root@server named]# chkconfig named on
Step # 7: Check DNS functionality:
## DIG :-
[root@server named]# dig server.example.com
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> server.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30604
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;server.example.com. IN A
;; ANSWER SECTION:
server.example.com. 86400 IN A 192.168.0.254
;; AUTHORITY SECTION:
example.com. 86400 IN NS server.example.com.
;; Query time: 0 msec
;; SERVER: 192.168.0.254#53(192.168.0.254)
;; WHEN: Thu Mar 1 10:17:20 2012
;; MSG SIZE rcvd: 66
[root@server named]#
Step # 1a: Configure the network Interface like this:
[root@server ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:1D:09:10:49:DC
inet addr:192.168.0.254 Bcast:192.168.0.255 Mask:255.255.255.0 ## DNS server machine Ethernet
inet6 addr: fe80::21d:9ff:fe10:49dc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:578841 errors:0 dropped:0 overruns:0 frame:0
TX packets:31217 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:59073403 (56.3 MiB) TX bytes:5895624 (5.6 MiB)
Interrupt:16
[root@server ~]#
Step # 1b: Set Host Configuration as follows:
[root@server named]# cat /etc/hosts
127.0.0.1 localhost.localdomain
::1 localhost.localdomain
192.168.0.254 server.example.com server
[root@server named]# cat /etc/resolv.conf
nameserver 192.168.0.254
search example.com
[root@server named]#
Step # 2: Install Bind.
[root@server ~]# yum install bind*
Step # 3: Edit named.conf: we need to change only three lines in this file:
[root@server ~]# vi /etc/named.conf
options {
listen-on port 53 { 192.168.0.254; }; ## Enter Your IP Here by !!
#listen-on-v6 port 53 { ::1; }; ## Comment this line
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; }; ## Allow Query to DNS from outside world
recursion yes;
.
.
. ## Keep other configuration as it is
.
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
Step # 4: We need to define our Zone file which is done in /etc/named.rfc1912.zones as follows:
[root@server named]# cat /etc/named.rfc1912.zones
zone "example.com" IN {
type master;
file "forward.zone"; ; Forward Zone will be defined in forward.zone
allow-update { none; };
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "reverse.zone"; ; Reverse Zone will be defined in reverse.zone
allow-update { none; };
};
[root@server named]#
Step # 5: Now we configure Forward Zone and Reverse Zone:
[root@server named]# cat /var/named/forward.zone
$TTL 1D
@ IN SOA server.example.com. root.server.example.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS server.example.com.
server IN A 192.168.0.254
test IN A 192.168.0.100 ; Like this we can any number of domains
[root@server named]#
[root@server named]# cat /var/named/reverse.zone
$TTL 1D
@ IN SOA server.example.com. root.example.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS server.example.com.
254 IN PTR server.example.com.
100 IN PTR test.example.com. ; Like this we can any number of domains
[root@server named]#
Step # 6: Start Bind.
[root@server named]# /etc/init.d/named start
Starting named: [ OK ]
[root@server named]#
[root@server named]# chkconfig named on
Step # 7: Check DNS functionality:
## DIG :-
[root@server named]# dig server.example.com
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> server.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30604
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;server.example.com. IN A
;; ANSWER SECTION:
server.example.com. 86400 IN A 192.168.0.254
;; AUTHORITY SECTION:
example.com. 86400 IN NS server.example.com.
;; Query time: 0 msec
;; SERVER: 192.168.0.254#53(192.168.0.254)
;; WHEN: Thu Mar 1 10:17:20 2012
;; MSG SIZE rcvd: 66
[root@server named]#
Let me know if you face any issues... :)