DNS server is used to resolve domain name into IP address. There are three common DNS server configurations can be done using BIND, caching nameserver, primary master and secondary master more info.
Here in this post we can see about how to install and configure DNS server in ubuntu 14.04.
DNS server installation
Step 1 » Update the repositories.
sudo apt-get update
Step 2 » Install bind9 using the below command.
sudo apt-get install bind9
Now installation is over, please proceed with configuration.
Caching nameserver
Caching nameserver will remember all the DNS queries made and serves locally when the domain is queried second time. Default configuration will act as a caching nameserver, you just need is to add public DNS IPs in the configuration file.
Step 3 » Open /etc/bind/named.conf.options file and find forwarders column , uncomment and edit like the following.
forwarders { 8.8.8.8; 8.8.4.4; };
Here 8.8.8.8 and 8.8.4.4 are google public DNS servers .
Step 4 » Now start/restart the service.
sudo service bind9 restart
Step 5 » Now test using dig command . open /etc/resolv.conf and edit nameserver ip to 127.0.0.1 or your serverIP.
nameserver 127.0.0.1
Now type the below command to see results.
krizna@ns:~$ dig www.krizna.com
It took 83 msec for the first time . Now try the same command again.
................
;; Query time: 83 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
.................
krizna@ns:~$ dig www.krizna.com
Now reduced to 5 msec . This time it serves from local.
................
;; Query time: 5 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
.................
Primary master
Primary master configuration is just like managing DNS records for particular domain locally ( Eg: krizna.com ).
Scenario details:
Domain name : krizna.com
Server ip : 192.168.6.5
Server hostname : ns.krizna.com
Webserver ip : 192.168.6.10 ( www.krizna.com) .
We need to create 2 zone files , Forward zone and reverse zone.
Forward zone file
Step 6 » Create forward zone file db.krizna.com by copying db.local conf file.
sudo cp /etc/bind/db.local /etc/bind/db.krizna.com
Step 7 » Now open /etc/bind/db.krizna.com and edit like below.
; BIND data file for local loopback interface ; $TTL 604800 @ IN SOA ns.krizna.com. root.ns.krizna.com. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS ns.krizna.com. @ IN A 192.168.6.5 @ IN AAAA ::1 ns IN A 192.168.6.5 www IN A 192.168.6.10
Reverse zone file
Step 7 » Create reverse zone file db.192 by copying db.172 conf file.
sudo cp /etc/bind/db.127 /etc/bind/db.192
Step 8 » Now open /etc/bind/db.192 file and edit like below.
; BIND reverse data file for local loopback interface ; $TTL 604800 @ IN SOA ns.krizna.com. root.ns.krizna.com. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS ns. 5 IN PTR ns.krizna.com. 10 IN PTR www.krizna.com.
Step 9 » Now open /etc/bind/named.conf.local configuration file and add the below lines to include forward and reverse zone files . 6.168.192 in reverse column is just first three octets of your network.
// Forward zone zone "krizna.com" { type master; file "/etc/bind/db.krizna.com"; }; //reverse zone zone "6.168.192.in-addr.arpa" { type master; file "/etc/bind/db.192"; };
Step 10 » Now restart the service.
sudo service bind9 restart
Step 11 » Now test using nslookup or dig commands.
krizna@ns:~$ nslookup www.krizna.com
Now test reverse lookup
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: www.krizna.com
Address: 192.168.6.10
krizna@ns:~$ nslookup 172.27.6.10
That’s it , Your DNS server is ready .
Server: 127.0.0.1
Address: 127.0.0.1#53
10.6.27.172.in-addr.arpa name = www.krizna.com.
Good tutorial , can you help me how l can add these DNS to cpanel where l am hosting a domain name ?
Good tutorial , can you help me how l can add these DNS to cpanel where l am hosting a domain name ?
dude can u tel me about how to make it external … i got angry about f**ing internal tutorials …. where is the point … come one do someting useful
dude can u tel me about how to make it external … i got angry about f**ing internal tutorials …. where is the point … come one do someting useful
I followed the instructions…but when i did the nslookup for my local domain i got a totally different ip address; while it should’ve read ‘192.168.1.6’ i got ‘192.105.244.228’.
I followed the instructions…but when i did the nslookup for my local domain i got a totally different ip address; while it should’ve read ‘192.168.1.6’ i got ‘192.105.244.228’.
i can’t do it in last step.
request high availability drbd pacemaker corosync in debian
Thank you!
sorry i have a problem. my name server is nik.com but when i input “dig http://www.nik.com” i recive error message “;; global options: +cmd
;; connection timed out; no servers could be reached”
why?
thank you