无法启动 dhcp 服务器

无法启动 dhcp 服务器

使用debian,并安装isc-dhcp-服务器通过以下命令

sudo apt -y install isc-dhcp-server

同意任何依赖项后,抛出以下错误消息

Job for isc-dhcp-server.service failed because the control process exited with error code.
See "systemctl status isc-dhcp-server.service" and "journalctl -xe" for details.

我重新启动了我的机器,并尝试运行以下命令

sudo service isc-dhcp-server start

这只是重新打印与上面相同的错误消息。

错误要求运行systemctl 状态 isc-dhcp-server.service返回

● isc-dhcp-server.service - LSB: DHCP server
     Loaded: loaded (/etc/init.d/isc-dhcp-server; generated)
     Active: failed (Result: exit-code) since Mon 2024-03-11 00:33:46 GMT; 12min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 2980 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)

sudo Journalctl -u isc-dhcp-server.service回报

isc-dhcp-server[5786]: Launching IPv4 server only.
dhcpd[5793]: /etc/dhcp/dhcpd.conf line 13: subnet 192.168.2.101 netmask 255.255.255.0: bad subnet number/mask combination.
dhcpd[5793]: subnet 192.168.2.101 netmask 255.255.255.0
dhcpd[5793]:                                          ^
dhcpd[5793]: Configuration file errors encountered -- exiting
dhcpd[5793]: 
dhcpd[5793]: If you think you have received this message due to a bug rather
dhcpd[5793]: than a configuration issue please read the section on submitting
isc-dhcp-server[5786]: dhcpd self-test failed. Please fix /etc/dhcp/dhcpd.conf.
isc-dhcp-server[5786]: The error was:
dhcpd[5793]: bugs on either our web page at www.isc.org or in the README file
dhcpd[5793]: before submitting a bug.  These pages explain the proper
dhcpd[5793]: process and the information we find helpful for debugging.
dhcpd[5793]: exiting.
dhcpd[5797]: Internet Systems Consortium DHCP Server 4.4.1
isc-dhcp-server[5797]: Internet Systems Consortium DHCP Server 4.4.1
isc-dhcp-server[5797]: Copyright 2004-2018 Internet Systems Consortium.
isc-dhcp-server[5797]: All rights reserved.
isc-dhcp-server[5797]: For info, please visit https://www.isc.org/software/dhcp/
dhcpd[5797]: Copyright 2004-2018 Internet Systems Consortium.
dhcpd[5797]: All rights reserved.
dhcpd[5797]: For info, please visit https://www.isc.org/software/dhcp/
dhcpd[5797]: /etc/dhcp/dhcpd.conf line 13: subnet 192.168.2.101 netmask 255.255.255.0: bad subnet number/mask combination.
dhcpd[5797]: subnet 192.168.2.101 netmask 255.255.255.0
isc-dhcp-server[5797]: /etc/dhcp/dhcpd.conf line 13: subnet 192.168.2.101 netmask 255.255.255.0: bad subnet number/mask combination.
isc-dhcp-server[5797]: subnet 192.168.2.101 netmask 255.255.255.0
isc-dhcp-server[5797]:                                          ^
isc-dhcp-server[5797]: Configuration file errors encountered -- exiting

我的机器配置文件

sudo nano /etc/dhcp/dhcpd.conf
...
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers 8.8.8.8;
...
subnet 192.168.2.101 netmask 255.255.255.0 {
  option routers pepper.spices.org;
}

...
authoritative;
...

sudo /etc/default/isc-dhcp-server
...
DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
...
INTERFACESv4="eth0"
...

答案1

错误告诉它:

isc-dhcp-server[5797]: /etc/dhcp/dhcpd.conf line 13: subnet 192.168.2.101 netmask 255.255.255.0: bad subnet number/mask combination.
isc-dhcp-server[5797]: subnet 192.168.2.101 netmask 255.255.255.0

bad subnet number/mask combination

实际上 192.168.2.101/255.255.255.0 是无效子网。子网与范围不同(范围是子网内部的一个区间,因此通常更窄)。当使用二进制基数查看时,子网中网络掩码的匹配位为 0 的所有位也必须为 0,否则就没有意义,因为这些是主机部分:

11000000.10101000.00000010。01100101(192.168.2。101
11111111.11111111.11111111.00000000 (255.255.255.255.0)

101 必须更改为 0 才能获得此宽度的有效子网(255.255.255.255.0 又名 /24,因为网络部分有 24 位)。

相反,应该用于从 192.168.2.101 开始到结束的范围(保留 0.254,以防pepper.spices.org解析为 192.168.2.254,这无法从问题中提供的信息推断出来)是:

subnet 192.168.2.0 netmask 255.255.255.0 {
    range 192.168.2.101 192.168.2.253;
    option routers pepper.spices.org;
}

相关内容