我目前正在研究 DNS,在我的 centos6 VM 中遇到了以下错误。这是我正在遵循的教程教程
[root@server1 named]# sudo service named start
Starting named:
Error in named configuration:
zone example.tv/IN: has no NS records
zone example.tv/IN: not loaded due to errors.
_default/example.tv/IN: bad zone
rev.example.tv:1: unknown RR type '1.168.192.in-addr.arpa.'
zone 1.168.192.in-addr.arpa/IN: loading from master file rev.example.tv failed: unknown class/type
zone 1.168.192.in-addr.arpa/IN: not loaded due to errors.
_default/1.168.192.in-addr.arpa/IN: unknown class/type
zone localhost.localdomain/IN: loaded serial 0
zone localhost/IN: loaded serial 0
zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 0
zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
zone 0.in-addr.arpa/IN: loaded serial 0
[FAILED]
[root@server1 named]#
这是我的 fwd.example.tv 文件:
$ORIGIN example.tv.
$TTL 86400
@ IN SOA server1.example.tv. root.example.tv. (
2018021011;serial
3600; refresh
1800;retry
604800; expire
86400;min TTL
)
@IN NS server1.example.tv.
@IN NS server2.example.tv.
server1 IN A 192.168.1.17
server2 IN A 192.168.1.20
~
~
这是我的 rev.example.tv 文件:
@ORIGIN 1.168.192.in-addr.arpa.
$TTL 86400
@ IN SOA server1.example.tv. root.example.tv.(
2018021011; serial
3600; refresh
1800;retry
604800; expire
86400; minimum TTL
)
@IN NS server1.example.tv.
@IN NS server2.example.tv.
server1 A 192.168.1.17
server2 A 192.168.1.20
17 IN PTR server1.example.tv.
20 IN PTR server2.example.tv.
~
~
这是我的 /etc/named.conf 文件:
Code: Select all
options {
listen-on port 53 { 127.0.0.1; 192.168.1.17; };
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 { localhost; 192.168.1.0/24; };
allow-transfer {localhost; 192.168.1.20; };
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 {
type hint;
file "named.ca";
};
zone "example.tv" IN{
type master;
file "fwd.example.tv";
allow-update {none;};
};
zone "1.168.192.in-addr.arpa" IN{
type master;
file "rev.example.tv";
allow-update{none;};
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
答案1
使用named-checkconf
和named-checkzone
检查您的配置和区域文件。
剧透警告:@IN
不是有效语法,必须阅读@ IN
。
答案2
我的问题的答案在于区域文件的构建方式,这种方式对我来说很有效,所以我发布了我的工作解决方案,供将来遇到同样问题的人使用。实际上,我忘记在 fwd.example.tv 文件和 rev.example.tv 文件中以正确的方式添加 example.tv. NS,所以这里是我的工作解决方案。
保持区域的正确方法如下:
$ORIGIN example.tv.
$TTL 86400
@ IN SOA server1.example.tv. root.example.tv. (
2018021000
3600
1800
604800
86400
)
@ IN NS server1.example.tv.
@ IN NS server2.example.tv.
server1 IN A 192.168.1.17
server2 IN A 192.168.1.20
example.tv. IN A 192.168.1.17
~
~
保留反向区域的正确方法如下:
$ORIGIN 1.168.192.in-addr.arpa.
$TTL 86400
@ IN SOA server1.example.tv. root.example.tv.(
2018021011; serial
3600; refresh
1800;retry
604800; expire
86400; minimum TTL
)
@ IN NS server1.example.tv.
@ IN NS server2.example.tv.
server1 A 192.168.1.17
server2 A 192.168.1.20
17 IN PTR server1.example.tv.
20 IN PTR server2.example.tv.
IN NS example.tv.
1 IN PTR example.tv.
~