Linux伺服器---安裝bind

一生有你llx發表於2018-12-11

安裝bind

1 、安裝bind軟體,需要安裝3 個bind、bind-chroot、bind-util

[root@localhost pub]#  yum install -y bind bind-chroot bind-utils

Installed:

  bind.i686 32:9.8.2-0.17.rc1.el6_4.6                                                                                     

Complete! 

 

2 、修改配置檔案“/etc/named.conf”,追加“forward”

[root@localhost pub]#  gedit /etc/named.conf

options {

    listen-on port 53 { 127.0.0.1; };

#   listen-on-v6 port 53 { ::1; };

    directory "/var/named";

    dump-file "/var/named/data/cache_dump.db";

        statistics-file "/var/named/data/named_stats.txt";

        memstatistics-file "/var/named/data/named_mem_stats.txt";

    allow-query     { localhost; };

    recursion yes;

 

    dnssec-enable yes;

    dnssec-validation yes;

    dnssec-lookaside auto;

 

    /* Path to ISC DLV key */

    bindkeys-file "/etc/named.iscdlv.key";

 

    managed-keys-directory "/var/named/dynamic";

     forward only;

    forwarders{

       8.8.8.8;   

    }

};

 

3 、設定防火牆,這裡需要用到53埠。需要開啟tcp和udp的53埠,記得重啟防火牆 

[root@localhost pub]#  gedit /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT

 

[root@localhost phpMyAdmin]#  service iptables restart

iptables :將鏈設定為政策  ACCEPT filter nat                [ 確定 ]

iptables :清除防火牆規則:                                  [ 確定 ]

iptables :正在解除安裝模組:                                    [ 確定 ]

iptables :應用防火牆規則:                                  [ 確定 ]

iptables :載入額外模組: nf_conntrack_ftp                   [ 確定 ]

[root@localhost phpMyAdmin]# 

 

4 、啟動服務

[root@localhost pub]# service named start

啟動 named                                               [ 確定 ]

[root@localhost pub]# 

 

5 、測試,命令格式“dig 網站@ip”,這裡用迴環地址來測試,看是否能請求成功

[root@localhost pub]#  dig www.baidu.com @127.0.0.1

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> www.baidu.com @127.0.0.1

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51491

;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:

;www.baidu.com.          IN  A

;; ANSWER SECTION:

www.baidu.com.       1191   IN  CNAME  www.a.shifen.com.

www.a.shifen.com. 299IN  A   14.215.177.38      // 這個就是請求到的結果

www.a.shifen.com. 299IN  A   14.215.177.39

;; Query time: 3053 msec

;; SERVER: 127.0.0.1#53(127.0.0.1)

;; WHEN: Tue Aug 14 19:02:59 2018

;; MSG SIZE  rcvd: 90

 

 

6 、更改配置檔案named.conf,讓所有機器都可以使用該服務。

1 )將配置檔案中的迴環地址改為any,意味著允許任何人使用

[root@localhost pub]#  gedit /etc/named.conf

options {

     listen-on port 53 {any; };

#   listen-on-v6 port 53 { ::1; };

    directory "/var/named";

    dump-file "/var/named/data/cache_dump.db";

        statistics-file "/var/named/data/named_stats.txt";

        memstatistics-file "/var/named/data/named_mem_stats.txt";

     allow-query     { any; };

    recursion yes;

 

    dnssec-enable yes;

    dnssec-validation yes;

    dnssec-lookaside auto;

 

    /* Path to ISC DLV key */

    bindkeys-file "/etc/named.iscdlv.key";

 

    managed-keys-directory "/var/named/dynamic";

     forward only;

    forwarders{

       8.8.8.8;   

    }

};

2 )找一個其他ip地址來測試

[root@localhost pub]#  service named restart   // 重啟服務

停止 named                                               [ 確定 ]

啟動 named                                               [ 確定 ]

 

[root@localhost pub]#  dig www.baidu.com @192.168.0.113

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> www.baidu.com @192.168.0.113

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37134

;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

 

;; QUESTION SECTION:

;www.baidu.com.          IN  A

 

;; ANSWER SECTION:

www.baidu.com.       871 IN  CNAME  www.a.shifen.com.

www.a.shifen.com. 299 IN  A   14.215.177.39

www.a.shifen.com. 299 IN  A   14.215.177.38

 

;; Query time: 474 msec

;; SERVER: 192.168.0.113#53(192.168.0.113)

;; WHEN: Tue Aug 14 19:06:19 2018

;; MSG SIZE  rcvd: 90

 

 

 


做了一個Linux學習的平臺,目前出來一個雛形,各位可以參考使用
連結: https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ   密碼:n7bk

Linux伺服器---安裝bind


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29270124/viewspace-2222068/,如需轉載,請註明出處,否則將追究法律責任。

相關文章