Custom Search

Ubuntu dns server configuration

Ubuntu dns server configuration involves many files. I would like to remind you again, please make a backup for every files before you begin editing. Example below:




luzar@ubuntu:/etc/bind$ sudo cp named.conf.local named.conf.local.bak
luzar@ubuntu:/etc/bind$ sudo cp named.conf.options named.conf.options.bak



The first file we are going to edit is the named.conf.local file. Use your favorite editor to open named.conf.local file.




luzar@ubuntu:/etc/bind$ sudo vim /etc/bind/named.conf.local



Type the code below. Replace example.com. with your domain name.





zone "example.com" in {
allow-transfer { any; };
file "/etc/bind/db.example.com.";
type master;
};


// Set up reversed name resolution
zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/db.192";
};



Example of /etc/bind/db.example.com configuration.





;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA ubuntu.example.com. root.example.com. (
2008112202 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
86400 ) ; Negative Cache TTL
;

example.com IN MX mail.example.com.
@ IN NS ubuntu.example.com.
@ IN A 192.168.1.3
ubuntu IN A 192.168.1.3
web IN CNAME ubuntu.example.com.



Example of /etc/bind/db.192 configuration.





;
; Reverse lookup DNS Zone file
;
$TTL 604800
@ IN SOA ubuntu.example.com. root.example.com. (
2008112302 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
86400 ) ; Negative Cache TTL
@ IN NS ubuntu.
3 IN CNAME ubuntu.example.com.



You have to set the ISP dns server ip address. Put it in /etc/bind/named.conf.options forwarders:





// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.


forwarders {
123.123.0.123;
123.123.1.1;
};



Example of /etc/resolv.conf configuration:

search example.comnameserver 192.168.1.3

Example of /etc/hosts configuration:





127.0.0.1 localhost
192.168.1.3 ubuntu.example.com ubuntu

# The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopbackfe00
::0 ip6-localnetff00
::0 ip6-mcastprefixff02
::1 ip6-allnodesff02
::2 ip6-allroutersff02
::3 ip6-allhosts



Restart bind9 service with the command below:




luzar@ubuntu:~$ sudo /etc/init.d/bind9 restart
* Stopping domain name service... bind [ OK ]
* Starting domain name service... bind [ OK ]

luzar@ubuntu:~$ tail /var/log/messages



Testing dns with dig domain name command:




luzar@ubuntu:/etc/bind$ dig example.com

; <<>> DiG 9.4.2-P2 <<>> example.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34700
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1,
ADDITIONAL: 1

;; QUESTION SECTION:;example.com. IN A


;; ANSWER SECTION:
example.com. 604800 IN A 192.168.1.3


;; AUTHORITY SECTION:
example.com. 604800 IN NS ubuntu.example.com.


;; ADDITIONAL SECTION:
ubuntu.example.com. 604800 IN A 192.168.1.3


;; Query time: 0 msec
;; SERVER: 192.168.1.3#53(192.168.1.3)
;; WHEN: Sun Nov 23 04:23:18 2008
;; MSG SIZE rcvd: 82


luzar@ubuntu:/etc/bind$



Testing with dig ip address:




luzar@ubuntu:/etc/bind$ dig -x 192.168.1.3


; <<>> DiG 9.4.2-P2 <<>> -x 192.168.1.3
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35746
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1,
ADDITIONAL: 0


;; QUESTION SECTION:
;3.1.168.192.in-addr.arpa. IN PTR


;; ANSWER SECTION:
3.1.168.192.in-addr.arpa. 604800 IN CNAME ubuntu.example.com.


;; AUTHORITY SECTION:
example.com. 86400 IN SOA ubuntu.example.com.
root.example.com. 2008112202 604800 86400 2419200 86400


;; Query time: 0 msec
;; SERVER: 192.168.1.3#53(192.168.1.3)
;; WHEN: Sun Nov 23 04:32:09 2008
;; MSG SIZE rcvd: 115
luzar@ubuntu:/etc/bind$



If you have an error during configuration, please check error logs in:





  • /var/log/daemon.log.

  • /var/log/messages.




Here is an example of /var/log/daemon.log:




luzar@ubuntu:/etc/bind$ tail /var/log/daemon.log

Nov 24 10:23:05 ubuntu named[4554]: zone 28.172.in-addr.arpa/IN:
loaded serial 1
Nov 24 10:23:05 ubuntu named[4554]: zone 29.172.in-addr.arpa/IN:
loaded serial 1
Nov 24 10:23:05 ubuntu named[4554]: zone 30.172.in-addr.arpa/IN:
loaded serial 1
Nov 24 10:23:05 ubuntu named[4554]: zone 31.172.in-addr.arpa/IN:
loaded serial 1
Nov 24 10:23:05 ubuntu named[4554]: zone 168.192.in-addr.arpa/IN:
loaded serial 1
Nov 24 10:23:05 ubuntu named[4554]: zone 1.168.192.in-addr.arpa/IN:
loaded serial 2008112302
Nov 24 10:23:05 ubuntu named[4554]: zone 255.in-addr.arpa/IN:
loaded serial 1
Nov 24 10:23:05 ubuntu named[4554]: zone example.com/IN:
loaded serial 2008112202
Nov 24 10:23:05 ubuntu named[4554]: zone localhost/IN:
loaded serial 2
Nov 24 10:23:05 ubuntu named[4554]: running

1 comment:

  1. I did receive an answer ( QUERY: 1, ANSWER: 0, AUTHORITY: 1,) is that because my domain name is not registered?

    ReplyDelete

Please keep comment relevant and strictly no spam will be tolerated. Thank you.