Centos:首次配置 DNS 服务器时出错,“选项:未找到命令”

Centos:首次配置 DNS 服务器时出错,“选项:未找到命令”

我正在从头开始配置 DNS 服务器,这是我第一次这样做。我已使用yum install -y bind bind-utils安装所需的工具。然后我/etc/sysconfig/named使用以下选项进行编辑(这些选项是来自互联网的示例选项):

# create new
 options {
    directory "/var/named";
    allow-query { localhost; 10.1.2.0/24; };
    allow-transfer { localhost; 10.1.2.0/24; };
    recursion yes;
};
controls {
    inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
view "internal" {
    match-clients {
        localhost;
        10.1.2.0/24;
    };
    zone "." IN {
        type hint;
        file "named.ca";
    };
    zone "amadeus.netvision" IN {
        type master;
        file "amadeus.netvision.lan";
        allow-update { none; };
    };
    zone "2.1.10.in-addr.arpa" IN {
        type master;
        file "2.1.10.db";
        allow-update { none; };
    };
    zone "localdomain" IN {
        type master;
        file "localdomain.zone";
        allow-update { none; };
    };
    zone "localhost" IN {
        type master;
        file "localhost.zone";
        allow-update { none; };
    };
    zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "named.local";
        allow-update { none; };
    };
    zone "255.in-addr.arpa" IN {
        type master;
        file "named.broadcast";
        allow-update { none; };
    };
    zone "0.in-addr.arpa" IN {
        type master;
        file "named.zero";
        allow-update { none; };
    };
};
view "external" {
    match-clients { any; };
    allow-query { any; };
    recursion no;
    zone "amadeus.netvision" IN {
        type master;
        file "amadeus.netvision.wan";
        allow-update { none; };
    };
};
include "/etc/rndc.key";

# allow-query ⇒ query range you permit
# allow-transfer ⇒ the range you permit to transfer zone info
# recursion ⇒ allow or not to search recursively
# view "internal" { *** }; ⇒ write for internal definition
# view "external" { *** }; ⇒ write for external definition
# For How to write for reverse resolving, Write network address reversely like below.
# 10.1.2.0/24
# network address ⇒ 10.1.2.0
# range of network ⇒ 10.1.2.0 - 10.0.0.255
# how to write ⇒ 0.0.10.in-addr.arpa
# 172.16.0.80/29
# network address ⇒ 172.16.0.80
# range of network ⇒ 172.16.0.80 - 172.16.0.87
# how to write ⇒ 80.0.16.172.in-addr.arpa

编辑文件后,我执行以下操作:service named restart并收到此警告/错误:

[root@srv ~]# service named restart
/etc/sysconfig/named: line 2: options: command not found
/etc/sysconfig/named: line 3: directory: command not found
/etc/sysconfig/named: line 4: syntax error near unexpected token `}'
/etc/sysconfig/named: line 4: `    allow-query { localhost; 10.1.2.0/24; };'
Stopping named: .                                          [  OK  ]
Starting named:                                            [  OK  ]
[root@srv ~]#

有人知道我为什么会收到这些警告/错误吗?

答案1

您应该编辑的配置文件是/etc/named.conf/etc/bind9/named.conf,具体取决于发行版。

/etc/sysconfig/named文件是一个源自的 shell 代码片段,/etc/init.d/named用于提供一些环境默认值。

查看named.conf(5)手册页以供参考。

答案2

bind 的主要配置是 /etc/named.conf 而不是 /etc/sysconfig/named

# rpm -ql bind | grep named.conf
/etc/named.conf

/etc/sysconfig/named 用于 BIND 命名进程选项

相关内容