2017年9月22日 星期五

Linux DNS Server 架設

環境:
Ubuntu 16.04
IP: 172.16.166.177


Step 1:
#apt-get install bind9
#apt-get install dnsutils

假設domain name是 example.com
預期定義兩組
www.example.com
mail.example.com

Step 2:
#vim /etc/bind/named.conf.options
options {
        directory "/var/cache/bind";

        // If there is a firewall between you and nameservers you want
        // to talk to, you may need to fix the firewall to allow multiple
        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113

        // 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 {
                168.95.1.1;
                8.8.8.8;
        };

        //========================================================================
        // If BIND logs error messages about the root key being expired,
        // you will need to update your keys.  See https://www.isc.org/bind-keys
        //========================================================================
        dnssec-validation auto;

        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { any; };
};

Step 3:
#vim /etc/bind/named.conf.local
zone "example.com.tw" {
        type master;
        file "/etc/bind/db.host";
};

zone "166.16.172.in-addr.arpa" {
        type master;
        file "/etc/bind/db.ip";
};


Step 4:
#cd /etc/bind
#cp db.empty db.host
#cp db.empty db.ip

Step 5:
#vim db.host



Step 6:
#vim db.ip


Step 7: 
#/etc/init.d/bind9 restart

Step 8:
# netstat -ltupn | grep named
tcp        0      0 172.16.166.177:53       0.0.0.0:*               LISTEN      5979/named
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      5979/named
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      5979/named
tcp6       0      0 :::53                   :::*                    LISTEN      5979/named
tcp6       0      0 ::1:953                 :::*                    LISTEN      5979/named
udp        0      0 172.16.166.177:53       0.0.0.0:*                           5979/named
udp        0      0 127.0.0.1:53            0.0.0.0:*                           5979/named
udp6       0      0 :::53                   :::*                                5979/named

Step 9:
#dig -x 127.0.0.1
#dig example.com.tw
#dig mx example.com.tw

Step 10:
到DUT上,把dns指向我架設的DNS Server
然後ping example.com.tw
確認有回應代表架設成功。


沒有留言:

張貼留言