在虚拟 Linux PC 中尝试启动 DNS 服务时出现以下错误
[root@mininat ~]# service named status
Redirecting to /bin/systemctl status named.service
named.service - Berkeley Internet Name Domain (DNS)
Loaded: loaded (/usr/lib/systemd/system/named.service; disabled)
Active: failed (Result: exit-code) since Wed 2015-03-04 03:36:40 EST; 1min 58s ago
Process: 6135 ExecStartPre=/usr/sbin/named-checkconf -z /etc/named.conf (code=exited, status=1/FAILURE)
Process: 6133 ExecStartPre=/usr/libexec/generate-rndc-key.sh (code=exited, status=0/SUCCESS)
Mar 04 03:36:40 mininat.benunets.com named-checkconf[6135]: _default/benu123.com/IN: unexpected end of input
Mar 04 03:36:40 mininat.benunets.com named-checkconf[6135]: zone localhost.localdomain/IN: loaded serial 2010052601
Mar 04 03:36:40 mininat.benunets.com named-checkconf[6135]: zone localhost/IN: loaded serial 2010052601
Mar 04 03:36:40 mininat.benunets.com named-checkconf[6135]: 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
Mar 04 03:36:40 mininat.benunets.com named-checkconf[6135]: zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
Mar 04 03:36:40 mininat.benunets.com named-checkconf[6135]: zone 0.in-addr.arpa/IN: loaded serial 0
Mar 04 03:36:40 mininat.benunets.com systemd[1]: named.service: control process exited, code=exited status=1
Mar 04 03:36:40 mininat.benunets.com systemd[1]: Failed to start Berkeley Internet Name Domain (DNS).
Mar 04 03:36:40 mininat.benunets.com systemd[1]: Unit named.service entered failed state.
Mar 04 03:38:36 mininat.benunets.com systemd[1]: Stopped Berkeley Internet Name Domain (DNS).
[root@mininat ~]# service named start
Redirecting to /bin/systemctl start named.service
Job for named.service failed. See 'systemctl status named.service' and 'journalctl -xn' for details.
[root@mininat ~]# service named status
Redirecting to /bin/systemctl status named.service
named.service - Berkeley Internet Name Domain (DNS)
Loaded: loaded (/usr/lib/systemd/system/named.service; disabled)
Active: failed (Result: exit-code) since Wed 2015-03-04 03:38:44 EST; 2s ago
Process: 6309 ExecStartPre=/usr/sbin/named-checkconf -z /etc/named.conf (code=exited, status=1/FAILURE)
Process: 6306 ExecStartPre=/usr/libexec/generate-rndc-key.sh (code=exited, status=0/SUCCESS)
Mar 04 03:38:44 mininat.benunets.com named-checkconf[6309]: zone benu123.com/IN: not loaded due to errors.
Mar 04 03:38:44 mininat.benunets.com named-checkconf[6309]: _default/benu123.com/IN: unexpected end of input
Mar 04 03:38:44 mininat.benunets.com named-checkconf[6309]: zone localhost.localdomain/IN: loaded serial 2010052601
Mar 04 03:38:44 mininat.benunets.com named-checkconf[6309]: zone localhost/IN: loaded serial 2010052601
Mar 04 03:38:44 mininat.benunets.com named-checkconf[6309]: 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
Mar 04 03:38:44 mininat.benunets.com named-checkconf[6309]: zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
Mar 04 03:38:44 mininat.benunets.com named-checkconf[6309]: zone 0.in-addr.arpa/IN: loaded serial 0
Mar 04 03:38:44 mininat.benunets.com systemd[1]: named.service: control process exited, code=exited status=1
Mar 04 03:38:44 mininat.benunets.com systemd[1]: Failed to start Berkeley Internet Name Domain (DNS).
Mar 04 03:38:44 mininat.benunets.com systemd[1]: Unit named.service entered failed state.
请在下面找到我的区域文件
[root@mininat ~]# vi /var/named/benu123.com
$TTL 86400
@ IN SOA benu123.com. root(
2010052601 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ; minimum
)
IN NS benu123.com
localhost IN A 127.0.0.1
localhost IN AAAA ::1
benu55 IN AAAA 2001::2222
benu89 IN AAAA 2002::2222
~
答案1
正如您所注意到的,Bind 无法启动的原因是启动前检查返回的错误情况:/usr/sbin/named-checkconf -z /etc/named.conf
。您需要修复该问题。
~区域文件末尾的孤独波浪号不是有效的资源记录,应该被删除。
您正在声明区域内的名称服务器:
IN NS benu123.com
A
而不为您的名称服务器创建记录。这完全是错误的。此外,不以结尾的资源记录.
将被视为 DNS 简写,并附加 $ORIGIN(区域名称),因此您现在所拥有的功能等同于:
IN NS benu123.com.benu123.com.
你也许应该想要这样的东西:
$ORIGIN benu123.com.
$TTL 86400
@ IN SOA benu123.com. root.benu123.com(
2014030401 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ; minimum
)
IN NS benu123.com.
@ IN A 192.168.1.1 ; replace this with the ip-address of your name-server
localhost IN A 127.0.0.1
localhost IN AAAA ::1
benu55 IN AAAA 2001::2222
benu89 IN AAAA 2002::2222
我使用了@另一个 DNS 简写技巧,它相当于 $ORIGIN 或域名 benu123.com。
答案2
NS 条目至少需要一条 A 或 AAAA 记录(并且很可能末尾有一个点,除非您的名称服务器名为 benu123.com.benu123.com)。