Tuesday, February 26, 2013

Install and configure bind9 as primary server on Ubuntu 12.10 (quick and dirty)


  • Install bind9 packages,
    • apt-get install bind9 dnsutils
  • Edit bind9 configuration file (/etc/bind/named.conf.local) with your fav editor into like this example. Please replace domain name and IP reverse with your requirement. 
# This is the zone definition. replace frozenhell.net with your domain name
zone "frozenhell.net" IN {
        type master;
        file "/etc/bind/zones/pri.frozenhell.net";
        };
# This is the zone definition for reverse DNS. replace 56.168.192 with your network address in reverse notation
zone "56.168.192.in-addr.arpa" IN {
     type master;
     file "/etc/bind/zones/pri.56.168.192.in-addr.arpa";
     allow-query { any; };
};


  • Create new folder,
mkdir /etc/bind/zones

  •  Create new IP reverse file. You can use your fav editor, but for this example, i'm using VIM.
 vi /etc/bind/zones/pri.56.168.192.in-addr.arpa 

  • Add this all following lines below on your IP reverse file. You can adjust domain name and IP reverse with own your needs.
$TTL 3600
;; replace example.com with yoour domain name, ns1 with your DNS server name.
;; The number before IN PTR frozenhell.net. is the machine address of the DNS server. in my case, it's 1, as my IP address is 192.168.56.101
@ IN SOA ns1.frozenhell.net. hostmaster.frozenhell.net. (
                                 01       ; Serial. Please update the number after updating the file!
                               1800     ; Refresh
                                600      ; Retry
                            1209600  ; Expire
                               3600 )   ; Negative Cache TTL
;; put your primary and secondary domain here!
;$ORIGIN 56.168.192.in-addr.arpa.
                   IN            NS           ns1.frozenhell.net.
                   IN            NS           ns2.frozenhell.net.
101            IN            PTR          ns1.frozenhell.net.
102            IN            PTR          ns2.frozenhell.net.
110            IN            PTR          mx1.frozenhell.net.
111            IN            PTR          mx2.frozenhell.net.
120            IN            PTR          www.frozenhell.net.
150            IN            PTR          mail.frozenhell.net.  
  • Create new zone domain file. You can use your fav editor, but for this example, i'm using VIM.
vim /etc/bind/zones/pri.frozenhell.net

  •  Add this all following lines below on your zone domain file. You can adjust domain name and IP with own your needs.
$TTL    3600

;; replace frozenhell.net with your domain name. Don't forget the . after the domain name! 
;; also, replace ns1 with the name of your DNS server

frozenhell.net.       IN      SOA     ns1.frozenhell.net. hostmaster.frozenhell.net. (
                          01 ; Serial. Please update the number after updating the file! 
                      1800  ; Refresh
                        600  ; Retry
                1209600  ; Expire
                      3600   ) ; Negative Cache TTL

;; put your primary and secondary domain here!
frozenhell.net. IN NS ns1.frozenhell.net.
frozenhell.net. IN NS ns2.frozenhell.net.

;; put your mail (snmp) server domain name here!
frozenhell.net. IN MX 10 mx1.frozenhell.net.
;; if you have other mail (snmp) server and change the primary number
frozenhell.net. IN MX 20 mx2.frozenhell.net.

;; replace subdomain name and IP with your needs
ns1 IN A 192.168.56.101
ns2 IN A 192.168.56.102
mx1 IN A 192.168.56.110
mx2 IN A 192.168.56.111
www IN A 192.168.56.120
ftp IN A 192.168.56.120
mail IN A 192.168.56.150

;; if you have alias domain name. Just put like this example
webmail IN CNAME mail
pop3 IN CNAME mail
m        IN CNAME www

  • Edit /etc/resolv.conf  delete all existing lines and change it into like this
nameserver 127.0.0.1

  • Restart bind9 daemon,
/etc/init.d/bind9 restart

  • Check your domain name query. Make sure you got right answer like this example,
nslookup mail.frozenhell.net
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: mail.frozenhell.net
Address: 192.168.56.15

  • Check your IP reverse query. Make sure you got right answer like this example, 
nslookup mail.frozenhell.net
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: mail.frozenhell.net
Address: 192.168.56.150

  • Done! 









No comments:

Post a Comment