![绑定 DNS 配置,dig 命令不解析名称](https://linux22.com/image/608705/%E7%BB%91%E5%AE%9A%20DNS%20%E9%85%8D%E7%BD%AE%EF%BC%8Cdig%20%E5%91%BD%E4%BB%A4%E4%B8%8D%E8%A7%A3%E6%9E%90%E5%90%8D%E7%A7%B0.png)
我正在使用带有 bind 9 的 Fedora 17。
我尝试手动配置网络的 DNS,编辑 /etc/named.conf:
options {
listen-on port 53 { localhost; };
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";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {//Per tutte le zone di cui non è autoritario;
type hint;
file "named.ca";
};
zone "gruppo13.labreti.it" {
type master;
file "gruppo13.labreti.it.zone";
};
zone "13.168.192.in-addr.arpa" IN {
type master;
file "gruppo13.labreti.it.reverse.zone";
}
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
PS:原始文件中还有更多制表符,我只是对其进行了编辑以将其格式化为代码。如果我使用 named-checkconf 查找语法错误,它会说一切正常。
这是 gruppo13.labreti.it.zone:
$TTL 48h
@ IN SOA gruppo13.labreti.it. master.gruppo13.labreti.it. (
2013032511
1d
2h
4w
1h
)
IN NS dns
MX 1 mail
localhost A 127.0.0.1
gruppo13.labreti.it. A 192.168.13.1
AAAA 2000:0::d:1
dns A 192.168.13.2
AAAA 2000:0::d:2
www A 192.168.13.8
AAAA 2000:0::d:8
ftp CNAME gruppo13.labreti.it.
mail A 192.168.13.3
AAAA 2000:0::d:3
PS:同样的事情对于此文件和以下文件有效。
这是 gruppo13.labreti.it.reverse.zone:
$TTL 48h
@ IN SOA gruppo13.labreti.it. master.gruppo13.labreti.it. (
2013032511
1d
2h
4w
1h
)
NS gruppo13.labreti.it.
2 PTR dns
8 PTR www
3 PTR mail
我使用以下命令进行命名启动:
$ sudo systemctl start named.service
然后我输入这个命令:
$ sudo ifconfig eth0 192.168.13.100 netmask 255.255.255.0 broadcast 192.168.13.255
此后,我编辑 resolv.conf,使 DNS 地址为 192.168.13.100。
但如果我运行 dig:
$ dig gruppo13.labreti.it
我没有得到答案,这是日志:
; <<>> DiG 9.9.2-rl.028.23-P1-RedHat-9.9.2-5.P1.fc17 <<>> gruppo13.labreti.it
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 58814
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;gruppo13.labreti.it. IN A
;; Query time: 13 msec
;; SERVER: 192.168.13.100#53(192.168.13.100)
;; WHEN: Mon Mar 25 23:31:28 2013
;; MSG SIZE rcvd: 48
答案1
如果按此顺序执行此操作,则需要重新加载 bind,然后它才能开始侦听此 IP。您可以通过以下方式检查 bind 正在侦听的位置:
netstat -an | grep :53
(对于正常查询,udp 很有趣,如下所示:
udp 0 0 127.0.0.2:53 0.0.0.0:*
udp 0 0 127.0.0.1:53 0.0.0.0:*
)