dhcpd.conf“遇到configuration文件错误”

我想设置isc-dhcp-server,但在使用dhcpd -t进行testing时,dhcp.conf文件会生成一个错误:

 ... /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"; } 

大部分文件是从文档复制和粘贴,所以我不知道问题可以在哪里…

你的问题似乎在于interface enp30s0; 线。 既然你用数字来表示选项,我不认为你需要指定接口。

dhcpd.conf 手册页 :

选项路由器204.254.239.1;

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

我一行一行地重新创build您的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"; } 

祝你好运!