我已经在 centos 7 上设置了 BIND DNS 服务器。我已经创建了主区域记录,如下所示:
$ttl 38400 loool.ro. IN SOA ns1.loool.ro. owner.yahoo.com. ( 1421842090 10800 3600 604800 38400 ) loool.ro. IN NS loool.ro. loool.ro. IN A 86.34.156.51 loool.ro. IN MX 10 loool.ro. loool.ro. IN NS ns1.loool.ro. ns1.loool.ro. IN A 86.34.156.51
86.34.156.51 是一个公共 IP 地址,我可以通过它访问服务器。端口 53 已打开,使用免费在线端口检查器检查。named.service 正在监听端口 53。域名已注册,ns1 也已注册。但是当我使用 dnslookup 工具检查时,ns1.loool.ro 答案没有出现,3 秒后超时。BIND
服务器配置文件如下:
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-transfer { none; }; 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"; pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; also-notify { }; allow-query { any; }; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; zone "." IN { type hint; file "named.ca"; }; zone "loool.ro" { type master; file "/var/named/loool.ro.hosts"; };
如果我使用 dig 从 localhost 检查,答案会出现并且正确,但从其他主机则不会出现。如果我将 allow-query 从任何主机设置为 localhost,则 messages.log 文件会记录被拒绝的查询和 IP 地址,因此查询会到达。
在 named.service 启动时,messages.log 显示以下内容:
1 月 21 日 14:31:35 servera named[38627]:使用默认 UDP/IPv4 端口范围:[1024, 65535]
1 月 21 日 14:31:35 servera named[38627]:使用默认 UDP/IPv6 端口范围:[1024, 65535]
1 月 21 日 14:31:35 servera named[38627]:监听 IPv4 接口 lo,127.0.0.1#53
1 月 21 日 14:31:35 servera named[38627]:监听 IPv4 接口 em1,10.10.10.100#53
1 月 21 日 14:31:35 servera named[38627]:监听 IPv4 接口 em1,86.34.156.51#53
使用 allow-query=localhost 显示以下内容:
Jan 21 14:30:55 servera named[38403]: client 109.99.188.88#54374 (loool.ro): query 'loool.ro/A/IN' denied Jan 21 14:31:08 servera named[38403]: client 74.125.17.211#53668 (loool.ro): query 'loool.ro/AAAA/IN' denied
问题是什么?如果允许查询,则 messages.log 上没有任何错误日志。这是网络配置问题还是 linux(端口或 selinux)和 BIND 服务器(配置错误)的问题?BIND 会删除查询吗?
挖:
loool.ro. 0 IN NS ns1.loool.ro. ;;
Received 71 bytes from 192.162.16.20#53(sec-dns-a.rotld.ro) in 88 ms
loool.ro. 38400 IN A 86.34.156.51
loool.ro. 38400 IN NS ns1.loool.ro.
loool.ro. 38400 IN NS loool.ro.
;; Received 101 bytes from 10.10.10.100#53(ns1.loool.ro) in 1 ms
正如 Andrew B 所建议的,我已经在本地主机(DNS服务器所在地)上捕获了数据包,结果如下,我希望有人知道这里的问题是什么或者出了什么问题:
$tcpdump -i em1 -vvv -s 0 -l -n port 53 tcpdump: listening on em1, link-type EN10MB (Ethernet), capture size 65535 bytes 82.79.24.76.14761 > 10.10.10.100.domain: [udp sum ok] 3532 [1au] A? loool.ro. ar: . OPT UDPsize=4096 OK (37) 22:50:49.723204 IP (tos 0x0, ttl 64, id 63258, offset 0, flags [none], proto UDP (17), length 115) 10.10.10.100.domain > 82.79.24.76.14761: [udp sum ok] 3532*- q: A? loool.ro. 1/1/2 loool.ro. [10h40m] A 86.34.156.51 ns: loool.ro. [10h40m] NS ns1.loool.ro. ar: ns1.loool.ro. [10h40m] A 86.34.156.51, . OPT UDPsize=4096 OK (87) 22:50:49.987990 IP (tos 0x0, ttl 64, id 35514, offset 0, flags [DF], proto UDP (17), length 72) 10.10.10.100.52857 > 193.231.100.130.domain: [udp sum ok] 2042+ PTR? 38.124.41.103.in-addr.arpa. (44)
答案1
无法从互联网查询您的名称服务器。虽然存在粘合,但如果您的名称服务器无法收到回复,则粘合也无济于事。
+trace
下面是与 lVlint67 类似的输出尾部,但+additional
设置了标志:
loool.ro. 86400 IN NS ns1.loool.ro.
ns1.loool.ro. 86400 IN A 86.34.156.51
dig: couldn't get address for 'ns1.loool.ro': no more
胶水记录在那里,但其他东西出错了。如果我尝试自己查询该名称服务器...
$ dig @86.34.156.51 loool.ro
; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> @86.34.156.51 loool.ro
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached
名称服务器无法访问,因此该域名已无法连接到互联网。此外,您只定义了一条 NS 记录。为了获得适当的弹性,您需要至少两个位于不同物理位置的名称服务器。注册商的网站真的不应该让您应用此配置。:(
我也建议阅读我们应该托管自己的名称服务器吗?。
答案2
看起来你缺少适当的胶水记录在您的注册处。
$ dig +trace loool.ro
; <<>> DiG 9.9.5 <<>> +trace loool.ro
;; global options: +cmd
. 929 IN NS j.root-servers.net.
. 929 IN NS m.root-servers.net.
. 929 IN NS e.root-servers.net.
. 929 IN NS f.root-servers.net.
. 929 IN NS l.root-servers.net.
. 929 IN NS g.root-servers.net.
. 929 IN NS h.root-servers.net.
. 929 IN NS k.root-servers.net.
. 929 IN NS c.root-servers.net.
. 929 IN NS a.root-servers.net.
. 929 IN NS d.root-servers.net.
. 929 IN NS i.root-servers.net.
. 929 IN NS b.root-servers.net.
. 929 IN RRSIG NS 8 0 518400 20150131050000 20150121040000 16665 . X95MjU0E0exFVnq9oEJBi/Dih/wwyDhI0NoJ10bj1jthr6kjVElQgZTH l9XepwZOzSWiTzBXrhiMCaAd4MBIiDpNVHl5r8P0BAiw7GfB2HAQkEcr WPTcJe9Y0JX6ruSbcD93gWbvd4/rHZXpgB13y6hWJNlY0zHuu7Iqv4h9 H8s=
;; Received 397 bytes from 8.8.8.8#53(8.8.8.8) in 1025 ms
ro. 172800 IN NS dns-at.rotld.ro.
ro. 172800 IN NS dns-ro.denic.de.
ro. 172800 IN NS sns-pb.isc.org.
ro. 172800 IN NS primary.rotld.ro.
ro. 172800 IN NS sec-dns-a.rotld.ro.
ro. 172800 IN NS sec-dns-b.rotld.ro.
ro. 86400 IN NSEC rocks. NS RRSIG NSEC
ro. 86400 IN RRSIG NSEC 8 1 86400 20150131050000 20150121040000 16665 . d0xAIZZ3+EiqsKePxYP/ym8OEvp4bywmHIUTSigk6CUie8512rpuvXM2 vAL5RRuXDdCCG/0nP4bfR6cz0dgN9lTLdJz68kd4nRYZcTsz5ZLZkQ1T zmyiKEzzRK7PAVUTTfMG94NrHzIIBwLTYdhOqHPWHN4TQC8NYf2hJlyQ CqI=
;; Received 613 bytes from 193.0.14.129#53(k.root-servers.net) in 1130 ms
loool.ro. 86400 IN NS ns1.loool.ro.
dig: couldn't get address for 'ns1.loool.ro': no more
答案3
iptables 可能阻止了连接。只需允许命名通过防火墙即可。
iptables -I INPUT 1 -p tcp -m tcp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 2 -p udp -m udp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --sport 53:65535 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p udp -m udp --sport 53:65535 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT