dhcpd.conf“遇到配置文件错误”

dhcpd.conf“遇到配置文件错误”

我想设置 isc-dhcp-server,但是 dhcp.conf 文件在测试时生成错误dhcpd -t

...
/etc/dhcp/dhcpd.conf line 6: expecting a parameter or declaration
authoritative;
              ^
Configuration file errors encountered -- exiting
...

cat /etc/dhcp/dhcpd.conf

# Configuration file for the ISC-DHCP Server 4.3.3
# Default sample file at /etc/dhcp/dhcpd.sample.conf


# global statements:
authoritative;
interface enp30s0;
option routers 192.168.100.1;
option domain-name-servers 192.168.178.1, 192.168.100.1;

subnet 192.168.100.0 netmask 255.255.255.0{
    range 192.168.100.10 192.168.100.110;
    default-lease-time 600;
    max-lease-time 7200;
}

# host declaration
host server {
    hardware ethernet 1c:c1:de:80:76:e8;
    fixed-address 192.168.100.10;
    option host-name "server";
}

host pc {
    hardware ethernet 1C:1B:0D:10:44:71;
    fixed-address 192.168.100.11;
    option host-name "PC";
}

大部分文件都是从文档中复制粘贴的,所以我不知道问题出在哪里......

答案1

您的问题似乎与该interface enp30s0;行有关。由于您以数字方式引用选项,因此我认为您不需要指定接口。

来自dhcpd.conf 手册页

选项路由器 204.254.239.1;

请注意,此处的地址是用数字指定的。这不是必需的 - 如果您的路由器上的每个接口都有不同的域名,则使用该接口的域名而不是数字地址是完全合法的。但是,在许多情况下,路由器的所有 IP 地址可能只有一个域名,因此在此处使用该名称是不合适的。

我逐行dhcpd.conf使用示例文件重新创建了它,但这就是它被破坏的原因。

这是我的工作版本:

# cat /usr/share/doc/dhcp*/dhcpd.conf.sample
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
option routers 192.168.100.1;
option domain-name-servers 192.168.178.1, 192.168.100.1;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# This is a very basic subnet declaration.
subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.10 192.168.100.110;
  default-lease-time 600;
  max-lease-time 7200;
}

# Hosts which require special configuration options can be listed in
# host statements.   If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
host server {
  hardware ethernet 1c:c1:de:80:76:e8;
  fixed-address 192.168.100.10;
  option host-name "server";
}

host pc {
    hardware ethernet 1C:1B:0D:10:44:71;
    fixed-address 192.168.100.11;
    option host-name "PC";
}

祝你好运!

相关内容