BIND <正向解析>
1.修改主配置文件
~]# vim /etc/named.rfc1912.zones zone "huying.com" IN { type master; file "huying.zone"; }; ~]# named-checkconf |
2.創建區域解析庫
[root@el7 named]# vim /var/named/huying.zone $TTL 1D ;緩存時間為 @ IN SOA ns1.huying.com. admin.huying.com. ( ;@本區域名可以@代替 201811 ;序列號 1H ;主從同步時間間隔為1小時 30M ;當主從故障時,重試同步時間為30分鐘 2H ;輔助DNS Server的失效時間 1D ;否定答案的緩存時間為 ) IN NS ns1.huying.com. ;定義該區域負責解析的DNS服務器 IN NS ns2.huying.com. ;多條記錄的name相同,則可以省略
IN MX 10 mx1.huying.com. ;定義郵件記錄 IN MX 20 mx2.huying.com.
$ORIGIN huying.com. ;表示域名省略時以這個地方定義的域名補上, ns1 IN A 192.168.1.1 ;定義NS記錄FQDN的A記錄 ns2 IN A 192.168.1.2
mx1 IN A 192.168.1.1 ;定義MX記錄的FQDN的A記錄 mx2 IN A 192.168.1.2
www IN A 192.168.1.1 ;定義A記錄
[root@el7 named]# named-checkzone "huying.com" huying.zone zone huying.com/IN: loaded serial 201811 OK |
3.修改權限重新加載服務
[root@el7 named]# chown :named huying.zone [root@el7 named]# rndc reload server reload successful
|
4.測試效果
查詢huying.com域內的NS記錄 [root@el7 named]# dig -t ns huying.com
; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> -t ns huying.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17093 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2
;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;huying.com. IN NS
;; ANSWER SECTION: huying.com. 86400 IN NS ns2.huying.com. huying.com. 86400 IN NS ns1.huying.con.
;; ADDITIONAL SECTION: ns2.huying.com. 86400 IN A 192.168.1.2
;; Query time: 1 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Wed May 09 16:34:08 CST 2018 ;; MSG SIZE rcvd: 101
查詢huying.com域內的MX記錄 [root@el7 named]# dig -t mx huying.com
; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> -t mx huying.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50975 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 4
;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;huying.com. IN MX
;; ANSWER SECTION: huying.com. 86400 IN MX 10 mx1.huying.com. huying.com. 86400 IN MX 20 mx2.huying.com.
;; AUTHORITY SECTION: huying.com. 86400 IN NS ns2.huying.com. huying.com. 86400 IN NS ns1.huying.con.
;; ADDITIONAL SECTION: mx1.huying.com. 86400 IN A 192.168.1.1 mx2.huying.com. 86400 IN A 192.168.1.2 ns2.huying.com. 86400 IN A 192.168.1.2
;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Wed May 09 16:36:07 CST 2018 ;; MSG SIZE rcvd: 173 |
BIND <正向解析>