2017/2/7 9:58:13 上海長寧 記錄一下自己搭建DNS服務(wù)器的過程
Linux下的DNS服務(wù)器通常使用 bind9 來搭建。
在線安裝:apt-get install bind9離線安裝: 下載 bind9 deb安裝包及其依賴包,附下載地址:復(fù)制所有deb包到宿主機/var/cache/apt/archives/運行apt-get install -f *.deb。安裝之后,在/etc/目錄下有bind/目錄 ll /etc/bind/ drwxr-xr-x 2 root root 4096 8月 18 11:39 ./ drwxr-xr-x 130 root root 12288 8月 18 11:51 ../ -rwxr-xr-x 1 root root 2389 8月 15 16:43 bind.keys* -rwxr-xr-x 1 root root 237 8月 15 16:43 db.0* -rwxr-xr-x 1 root root 271 8月 15 16:43 db.127* -rwxr-xr-x 1 root root 237 8月 15 16:43 db.255* -rwxr-xr-x 1 root root 353 8月 15 16:43 db.empty* -rwxr-xr-x 1 root root 270 8月 15 16:43 db.local* -rwxr-xr-x 1 root root 2994 8月 15 16:43 db.root* -rwxr-xr-x 1 root root 463 8月 15 16:43 named.conf* -rwxr-xr-x 1 root root 490 8月 15 16:43 named.conf.default-zones* -rwxr-xr-x 1 root root 327 8月 15 16:43 named.conf.local* -rwxr-xr-x 1 root root 890 8月 15 16:43 named.conf.options* -rwxr-xr-x 1 root root 77 8月 15 16:43 rndc.key* -rwxr-xr-x 1 root root 1317 8月 15 16:43 zones.rfc1918*//// Do any local configuration here//// Consider adding the 1918 zones here, if they are not used in your// organization//include "/etc/bind/zones.rfc1918";zone "dzc.com" {type master;file "/etc/bind/db.dzc.com";};zone "20.10.10.in-addr.arpa" {type master;notify no;file "/etc/bind/db.20.10.10.in-addr.arpa";};添加了正向域 dzc.com 和對應(yīng)文件 /etc/bind/db.dzc.com添加了反向域 20.10.10.in-addr.arpa 和對應(yīng)文件 /etc/bind/db.20.10.10.in-addr.arpa 反向域的命名規(guī)則是到這些的IP地址。修改域文件
注意:在修改正向域和反向域文件時,不使用空格,而應(yīng)該使用TAB鍵隔開。域名后有個點,不要忘了。
配置正向解析域:vim db.dzc.com 復(fù)制正向域模板文件 db.local 并改名為 db.dzc.com 。;; BIND data file for local loopback interface;$TTL 604800@ IN SOA dzc.com. root.dzc.com. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL;@ IN NS dzc.com.@ IN A 127.0.0.1@ IN AAAA ::1www IN A 10.10.20.11test IN A 10.10.20.12配置反向解析域:vim db.20.10.10.in-addr.arpa 復(fù)制反向域模板文件 db.127 并改名為 db.20.10.10.in-addr.arpa 。;; BIND reverse data file for local loopback interface;$TTL 604800@ IN SOA dzc.com. root.dzc.com. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL;@ IN NS dzc.com.1.0.0 IN PTR localhost.11 IN PTR www.dzc.com.12 IN PTR test.dzc.com.重啟DNS服務(wù)器:service bind9 restart配置客戶機的DNS服務(wù)器為宿主機的ip:10.10.20.11在服務(wù)器更改重啟后,所有客戶機應(yīng)當(dāng)重啟網(wǎng)卡或清空DNS緩存。win10系統(tǒng)特別注意,有時候重啟網(wǎng)卡無效,必須清空DNS緩存。在cmd命令行窗口下,輸入:ipconfig /?系統(tǒng)會列出包含DNS的各項指令。ipconfig /dispalydns (顯示DNS記錄)ipconfig /flushdns(清空DNS緩存)。
新聞熱點
疑難解答
圖片精選