本文介绍 4 种 DNS 异常情况的模拟,分别为
server fail,ICMP port unreachable,No such name,Query refused. 下面为使用bind9模拟出 4 种异常情况的方法,本次使用ptb.de这个域名来模拟各种情况。
# server fail
当 DNS server 没有根域名的时候,会回
server fail,所以只要把根域名注释掉就可以模拟。
1. 编辑 db.ptb.de , 将 NS 记录用 ; 注释掉
$TTL 604800 | |
@ IN SOA ptb.de. root.ptb.de. ( | |
2 ; Serial | |
604800 ; Refresh | |
86400 ; Retry | |
2419200 ; Expire | |
604800 ) ; Negative Cache TTL | |
; | |
; A records | |
;@ IN NS localhost. | |
@ IN A 192.168.100.9 | |
;ptbtime1 IN A 194.25.134.196 | |
;ptbtime1 IN AAAA 2003:2:2:140:194:25:134:196 |
2. 重启 bind9
sudo /etc/init.d/bind9 restart |
3. 可以用 nslookup 实验一下是否实现
PS C:\Users\Administrator> nslookup.exe ptbtime1.ptb.de 192.168.100.9 | |
服务器: UnKnown | |
Address: 192.168.100.9 | |
*** UnKnown 找不到 ptbtime1.ptb.de: Server failed |
# ICMP port unreachable
1. 停止 bing9 服务
sudo /etc/init.d/bind9 stop |
2. 使用 nslookup 验证一下
PS C:\Users\Administrator> nslookup.exe ptbtime1.ptb.de 192.168.100.9 | |
服务器: UnKnown | |
Address: 192.168.100.9 | |
*** UnKnown 找不到 ptbtime1.ptb.de: No response from server |
# No such name
存在
zone, 但没有对应的子域名时回复No such name
1. 将文件 db.ptb.de 中对应的域名注释掉,然后
$TTL 604800 | |
@ IN SOA ptb.de. root.ptb.de. ( | |
2 ; Serial | |
604800 ; Refresh | |
86400 ; Retry | |
2419200 ; Expire | |
604800 ) ; Negative Cache TTL | |
; | |
; A records | |
@ IN NS localhost. | |
@ IN A 192.168.100.9 | |
;ptbtime1 IN A 194.25.134.196 | |
;ptbtime1 IN AAAA 2003:2:2:140:194:25:134:196 |
2. 重启 bind9
sudo /etc/init.d/bind9 restart |
3. 使用 nslookup 验证一下
PS C:\Users\Administrator> nslookup.exe ptbtime1.ptb.de 192.168.100.9 | |
服务器: UnKnown | |
Address: 192.168.100.9 | |
*** UnKnown 找不到 ptbtime1.ptb.de: Non-existent domain |
# Query refused
没有对应域名的
zone时,回复Query refuse
1. 修改 named.conf.local , 将对应的 zone 删除或者用 // 注释
// | |
// 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 "ptb.de" { | |
//type master; | |
//file "/etc/bind/db.ptb.de"; | |
//}; |
2. 重启 bind9
sudo /etc/init.d/bind9 restart |
3. 使用 nslookup 验证一下
PS C:\Users\Administrator> nslookup.exe ptbtime1.ptb.de 192.168.100.9 | |
服务器: UnKnown | |
Address: 192.168.100.9 | |
*** UnKnown 找不到 ptbtime1.ptb.de: Query refused |