我已经遵循了几个关于安装自己的名称服务器的教程,而且我的智慧已经很高了,因为我无法解决它们。 请注意,实际的域名和IP地址已被隐私更改为example.com和192.168.0.1。 我的named.conf.local文件:
zone "example.com" { type master; file "/var/cache/bind/example.com.db"; }; zone "0.168.192.in_addr.arpa" { type master; file "/var/cache/bind/192.168.0.db"; };
我的named.conf.options文件:
options { forwarders { 192.168.0.1; }; auth-nxdomain no; # conform to RFC1035 listen-on-v6 { any; }; };
我的resolv.conf文件:
search example.com. nameserver 192.168.0.1
我的转发DNS文件:
ORIGIN example.com. $TTL 86400 @ IN SOA ns1.example.com. root.example.com. ( 2012083101 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 3600 ) ; Negative Cache TTL example.com. NS ns1.example.com. example.com. NS ns2.example.com. example.com. MX 10 mail.example.com. @ IN A 192.168.0.1 ns1.example.com IN A 192.168.0.1 ns2.example.com IN A 192.168.0.2 mail IN A 192.168.0.1 server1 IN A 192.168.0.1 gateway IN CNAME ns1.example.com. headoffice IN CNAME server1.example.com. smtp IN CNAME mail.example.com. pop IN CNAME mail.example.com. imap IN CNAME mail.example.com. www IN CNAME server1.example.com. sql IN CNAME server1.example.com.
而我的反向DNS:
$ORIGIN 0.168.192.in-addr.arpa. $TTL 86400 @ IN SOA ns1.example.com. root.example.com. ( 2009013101 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 3600 ) ; Negative Cache TTL 1 PTR mail.example.com. 1 PTR server1.example.com. 2 PTR ns1.example.com.
然而,当我重新启动bind9,并做:
host ns1.example.com localhost
我得到:
Using domain server: Name: localhost Address: 127.0.0.1#53 Aliases: Host ns1.example.com.example.com not found: 2(SERVFAIL)
同样,对于:
host 192.168.0.1 localhost
我得到:
;; connection timed out; no servers could be reached
有人知道发生了什么事? 顺便说一句,我在这个问题中使用的域名“www.example.com”正在转发给我的ISP的域名服务器。 会影响我的bind9configuration吗? 我想学习如何自己设置名字服务器来学习,所以这就是为什么我要经历这些麻烦。
这两个答案都是好的..绑定一个工具,你可以用它来检查区域/ conf文件
named-checkzone domain.com /path/to/domain.com.zone
也有
named-checkconf
检查你的configuration。
用_
replace_
作为in-addr
。
zone "0.168.192.in_addr.arpa" { ... };
应该
zone "0.168.192.in-addr.arpa" { ... };
有问题的条目在这里:
ns1.example.com IN A 192.168.0.1 ns2.example.com IN A 192.168.0.2
如果您还没有用句点来终止,那么您的域名将被添加到每个域名的末尾。 为了得到它的工作,将它们改为:
ns1 IN A 192.168.0.1 ns2 IN A 192.168.0.2
您还需要进行@Zoredache所做的更改以修复您的反向DNS(但以后您将不会发现此问题)
首先要做的事情在启动named之后,确保它仍然在运行,并且没有退出某种错误。 名称是否在ps输出中显示? 什么是日志logging到系统日志? 你configuration了rndc吗? 如果是这样,“rndc status”是什么意思? 当你得到SERVFAIL和“连接超时”消息(如上所述)时,你需要确保你正在和一个在线服务器交谈。
除了系统日志以外的其他地方吗? (你只会向我们展示你的named.conf的一个子集,所以我不确定主named.conf是否有声明日志信息的日志信息。
检查ps以确保named正在运行,并检查syslog,看它是否在尝试启动时抱怨什么。
除此之外,在configuration中声明转发器的行可以完成什么?
准备testing时,使用完全限定的域名(FQDN)进行testing,例如:
dig ns1.example.com. @localhost
以避免混淆像你上面的情况:
Host ns1.example.com.example.com not found: 2(SERVFAIL)
(可以看到,由于resolv.conf文件中的search规则,“example.com”被添加到已经包含它的域名中。您可以通过使用FQDN消除歧义。)