2016年3月3日 星期四

DNS Server setup and config

Purpose: mapping server to IP address
  • DNS  Server       192.168.136.53
  • SMTP Server       192.168.136.25
  • POP3 Server       192.168.136.110
  • Webmail Server    192.168.136.80

domain name <-> IPv4 address
  • ns.lab.local        IN A      192.168.136.53
  • smtp.lab.local      IN A      192.168.136.25
  • pop3.lab.local      IN A      192.168.136.110
  • www.lab.local       IN A      192.168.136.80

Answer:


1. Since we only have one test machine (VM), try to add necessary IP address at the same host

$ ifconfig | grep Ethernet | awk '{print $1}' | awk '{ printf("sudo ifconfig %s:0 192.168.136.53\nsudo ifconfig %s:1 192.168.136.25\nsudo ifconfig %s:2 192.168.136.110\nsudo ifconfig %s:3 192.168.136.80\n", $1, $1, $1, $1); }'

2. install bind9

$ sudo apt-get -y install bind9

3. configure with minimal steps

$ sudo vim /etc/bind/named.conf.options

options {
        directory "/var/cache/bind";
        forwarders {
                8.8.8.8;
        };
        dnssec-validation auto;
        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { any; };
};

$ sudo vim /etc/bind/named.conf.local

zone "lab.local" {
        type master;
        file "/etc/bind/lab.local.db";
};

zone "136.168.192.in-addr.arpa" {
        type master;
        notify no;
        file "/etc/bind/rev.136.168.192.in-addr.arpa";
};

$ sudo vim /etc/bind/lab.local.db


$TTL 604800
@ IN SOA ns.lab.local. admin.lab.local. (
   2016         ; Serial
 604800         ; Refresh
  86400         ; Retry
2419200         ; Expire
 604800 )       ; Negative Cache TTL
;
;
@ IN NS      ns.lab.local.
@ IN MX  10  smtp.lab.local.
;
ns        IN A      192.168.136.53
smtp      IN A      192.168.136.25
pop3      IN A      192.168.136.110
www       IN A      192.168.136.80

$ sudo vim /etc/bind/rev.136.168.192.in-addr.arpa

$TTL 604800
@ IN SOA ns.lab.local. admin.lab.local. (
          2016         ; Serial
        604800         ; Refresh
         86400         ; Retry
        419200         ; Expire
        604800 )       ; Negative Cache TTL
;
;
53      IN      PTR     ns.lab.local.
25      IN      PTR     smtp.lab.local.
110     IN      PTR     pop3.lab.local.
80      IN      PTR     www.lab.local.

$ sudo service bind9 restart

$ sudo netstat -tupln | grep named | grep 53:53
tcp        0      0 192.168.136.53:53       0.0.0.0:*               LISTEN      9028/named      
udp        0      0 192.168.136.53:53       0.0.0.0:*                           9028/named

$ sudo update-rc.d bind9 defaults


Verification







沒有留言:

張貼留言