我在运行 Debian Wheezy 的开发虚拟机上设置了一个 Bind9 DNS 服务器。我的地址从主机 (Win7) 解析到开发虚拟机,我可以从那里 ping 通。在虚拟机内部,我可以 ping 我的名称(www、share、my_name 等),它会解析为正确的 IP(11.11.11.11)。但是当我 ping 我的完整 FDQN(www.app.dev)时,它会解析为 localhost。这对于 my_name.app.dev 来说并不成立,只有我的 /etc/bind/ 文件夹中的 db.app.dev 文件中的 CNAME 条目才成立。因此,如果我 ping www,解析为 11.11.11.11,www.app.dev 解析为 127.0.0.1。从 DNS 虚拟机外部 ping www.app.dev 或仅 www 都可以正常解析。这是预期行为还是我遗漏了什么?
这些是我认为你需要的文件。我添加了 resolv.conf,以防出现问题。
/etc/bind/zones/db.app.dev
$TTL 604800
@ IN SOA app.dev. root.app.dev. (
15 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
app.dev. IN NS my_name.app.dev.
app.dev. IN A 11.11.11.11
;@ IN A 127.0.0.1
;@ IN AAAA ::1
my_name IN A 11.11.11.11
gateway IN A 11.11.11.2
vmhost IN A 11.11.11.1
www IN CNAME app.dev.
stream IN CNAME app.dev.
/etc/bind/named.conf.local
include "/etc/bind/zones.rfc1918";
zone "app.dev" {
type master;
file "/etc/bind/zones/db.app.dev";
};
zone "11.11.11.in-addr.arpa" {
type master;
file "/etc/bind/zones/db.11";
};
/etc/resolv.conf
domain app.dev
search app.dev
nameserver 11.11.11.11
这是主机文件 /etc/hosts
127.0.0.1 localhost
11.11.11.11 my_name.app.dev my_name
# The following lines are desirable for IPv6 capable hosts
#::1 localhost ip6-localhost ip6-loopback
#ff02::1 ip6-allnodes
#ff02::2 ip6-allrouters
挖掘提供:
dig www.app.dev any #=>
; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> www.app.dev any
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51223
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;www.app.dev. IN ANY
;; ANSWER SECTION:
www.app.dev. 604800 IN CNAME app.dev.
;; AUTHORITY SECTION:
app.dev. 604800 IN NS my_name.app.dev.
;; ADDITIONAL SECTION:
my_name.app.dev. 604800 IN A 11.11.11.11
;; Query time: 2 msec
;; SERVER: 11.11.11.11#53(11.11.11.11)
;; WHEN: Wed Aug 13 12:48:15 2014
;; MSG SIZE rcvd: 78
这是 ping:ping www.app.dev
PING www.app.dev (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.035 ms
64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.032 ms
64 bytes from localhost (127.0.0.1): icmp_req=3 ttl=64 time=0.038 ms
^C
--- www.app.dev ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.032/0.035/0.038/0.002 ms
答案1
如果您在 hosts 文件 (/etc/hosts) 中将 www 设置为您的计算机主机名,它将首先从本地计算机进行解析(在设置解析器之前会先检查 hosts)。检查您的 hosts 文件...
答案2
我忘了isc-bind
默认日志存放在何处;因此请考虑将以下内容添加到您的 中named.conf
。这是我过去 10 年左右使用的日志配置。它可能有点多余;但它不应该遗漏任何东西。我在 FreeBSD 上运行;因此日志的位置可能并不完美。您还必须创建子目录namedb
并使其可由 BIND 写入(在我的情况下是bind:wheel 755
)。在您确定您具有良好的日志记录后(您可能已经),grep
在error
中/var/log/namedb/general
。
您这样做是为了确保named
您的配置满意。
(实际上,我将所有这些都放在一个名为的文件中named.logs
,然后将其复制include
。自从第 9 版删除“统计”类别以来,内容就没有改变过。)
logging {
channel "default_debug" {
file "/var/log/named.run"; // Redefine the built-in debug
// channel; so named.run is
// written to a consistent location
severity dynamic; // log at the server's
// current debug level
};
channel "default" {
file "/var/log/default" versions 3 size 100k;
severity debug;
//severity debug 3;
print-category yes;
print-severity yes;
print-time yes;
};
channel "general" {
file "/var/log/general" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "database" {
file "/var/log/database" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "security" {
file "/var/log/security" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "resolver" {
file "/var/log/resolver" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "xfer" {
file "/var/log/xfer" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "notify" {
file "/var/log/notify" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "client" {
file "/var/log/client" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "unmatched" {
file "/var/log/unmatched" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "network" {
file "/var/log/network" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "update" {
file "/var/log/update" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "queries" {
file "/var/log/query.log" versions 3 size 5m;
//severity debug;
//print-category yes;
//print-severity yes;
print-time yes;
};
channel "dispatch" {
file "/var/log/dispatch" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "dnssec" {
file "/var/log/dnssec" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "lame-servers" {
file "/var/log/lamoes" versions 3 size 100k;
severity debug;
print-category yes;
print-severity yes;
print-time yes;
};
channel "statistics" {
// This is for cricket
file "/var/log/stats.log" versions 3 size 1k;
};
category "default" { "default"; };
category "general" { "general"; };
category "database" { "database"; };
category "security" { "security"; };
category "config" { "general"; };
category "resolver" { "resolver"; };
category "xfer-in" { "xfer"; };
category "xfer-out" { "xfer"; };
category "notify" { "notify"; };
category "client" { "client"; };
category "unmatched" { "unmatched"; };
category "network" { "network"; };
category "update" { "update"; };
category "queries" { "queries"; };
category "dispatch" { "dispatch"; };
category "dnssec" { "dnssec"; };
category "lame-servers" { "lame-servers"; };
// category "statistics" { "statistics"; };
};
如果很明显named
运行时没有错误,您需要做一些事情dig's
(按照@Håkan Lindqvist 的要求查看具体报告的内容。例如:
dig @127.0.0.1 my_name.app.dev.
dig @11.11.11.11 my_name.app.dev.
Windows 没有dig
;因此您只能使用弃用的版本nslookup
,并且(我相信)必须使用交互模式。指定各种“服务器”并查询“my_name.app.dev”。
请让我们知道您看到了什么。