Ubuntu DNS server 設置

一、    DNS說明

        DNS使用端口號:53

           正解與反解說明:

               正解:通過Domain(DNS下的hostname)應射IP;通過hostname去找IP

               反解:通過IP反查hostname

           Zone(區域):一個正解或一個反解的設定就是一個zone

 

二、    安裝DNS的套件:bind9

         sudo apt-get install bind9

          查看安裝後的相關目錄文件:sudo dpkg – L bind9

             查看端口是否已啓動:netstat – tunlp | grep 53 

三、    DNS設定:

         配置環境:DNS Server IP:192.168.1.254 ,hostname:samba.elantech.com

            在DNS Server下的配置文件有如下:

                    /etc/bind/named.conf.options        //全局設置

                    /etc/bind/named.conf.default-zone    //添加或刪除zone的配置

                    /etc/bind/db.127                   //本機反解

                    /etc/bind/db.local                  //本機正解

四、    DNS Server 配置:

        配置步驟如下:

          

1、修改全局選項   sudo vi /etc/bind/named.conf.options

              轉發的IP地址修改成廣東電信的DNS IP:

forwarders {

                202.96.128.143;

         };

 

           2、添加zone  sudo vi /etc/bind/named.conf.default-zone

              添加2個zone ,“db.elantech.com”用來正解、“db.192”是用來反解

             

          zone "elantech.com"  {

                 type master;

                 file "/etc/bind/db.elantech.com";

};

 

zone "1.168.192.in-addr.arpa" {

                    type master;

                    file "/etc/bind/db.192";

};

 

3、設定DNS的正解:sudo cp /etc/bind/db.local /etc/bind/db.elantech.com

                  

 root@samba:/etc/bind# vi db.elantech.com

;

; BIND data file for local loopback interface

;

$TTL    604800

@       IN      SOA     elantech.com. root.elantech.com. (

                              2         ; Serial

                         604800         ; Refresh

                          86400         ; Retry

                        2419200         ; Expire

                         604800 )       ; Negative Cache TTL

;

@       IN      NS      elantech.com.

@       IN      A       192.168.1.254

samba   IN      A       192.168.1.254         

 

4、設定DNS的反解:  sudo cp /etc/bind/db.127 /etc/bind/db.192

 

root@samba:/etc/bind# vi db.192

;

; BIND reverse data file for local loopback interface

;

$TTL    604800

@       IN      SOA     elantech.com. root.elantech.com. (

                              1         ; Serial

                         604800         ; Refresh

                          86400         ; Retry

                        2419200         ; Expire

                         604800 )       ; Negative Cache TTL

;

@       IN      NS      elantech.com.

1.0.0   IN      PTR     samba.elantech.com.

254     IN      PTR   samba.elantech.com.

 

5、啓動bind服務: sudo /etc/inti.d/bind9 restart

 

6、查看啓動bind服務的日誌: tail /var/log/syslog

 

root@samba:/etc/bind# tail /var/log/syslog

Aug  3 10:15:14 samba named[1228]: command channel listening on ::1#953

Aug  3 10:15:14 samba named[1228]: zone 0.in-addr.arpa/IN: loaded serial 1

Aug  3 10:15:14 samba named[1228]: zone 127.in-addr.arpa/IN: loaded serial 1

Aug  3 10:15:14 samba named[1228]: zone 1.168.192.in-addr.arpa/IN: loaded serial 1

Aug  3 10:15:14 samba named[1228]: zone 255.in-addr.arpa/IN: loaded serial 1

Aug  3 10:15:14 samba named[1228]: zone elantech.com/IN: loaded serial 2

Aug  3 10:15:14 samba named[1228]: zone localhost/IN: loaded serial 2

Aug  3 10:15:14 samba named[1228]: managed-keys-zone ./IN: loading from master file managed-keys.bind failed: file not found

Aug  3 10:15:14 samba named[1228]: managed-keys-zone ./IN: loaded serial 0

Aug  3 10:15:14 samba named[1228]: running

 

7、在本機(192.168.1.254)上設置DNS :sudo /etc/resolv.conf

                       添加一行, nameserver 192.168.1.254

五、    測試DNS

1、 在DNS Server端

       命令:host samba.elantech.com (正解)

            samba.elantech.com has address 192.168.1.254

       命令:host 192.168.1.254     (反解)

      254.1.168.192.in-addr.arpa domain name pointer samba.elantech.com.

2、 在客戶端

       命令: nslookup www.baidu.com

                 C:\Documents and Settings\Administrator>nslookup www.baidu.com

Server:  samba.elantech.com

Address:  192.168.1.254

 

Non-authoritative answer:

Name:    www.a.shifen.com

Addresses:  220.181.112.143, 220.181.111.148

Aliases:  www.baidu.com

參考:

http://wenku.baidu.com/view/7e97a35777232f60dccca101.html

發佈了26 篇原創文章 · 獲贊 47 · 訪問量 59萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章