DHCP服务启动报“bad subnet number/mask combination.”的解决办法

DHCP服务启动报“bad subnet number/mask combination.”的解决办法

自家的linux服务器上搭建DHCP服务在重启后出现报错,但是光看表面的原因根本看不出啥= =:

[root@localhost log]# systemctl restart dhcpd
Job for dhcpd.service failed because the control process exited with error code.
See "systemctl status dhcpd.service" and "journalctl -xe" for details.
[root@localhost log]# systemctl status dhcpd
● dhcpd.service - DHCPv4 Server Daemon
   Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2020-11-27 09:56:37 CST; 19s ago
     Docs: man:dhcpd(8)
           man:dhcpd.conf(5)
  Process: 78463 ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid $DHCPDARGS (code=exi>
 Main PID: 78463 (code=exited, status=1/FAILURE)

11月 27 09:56:37 localhost.localdomain dhcpd[78463]: Configuration file errors encountered -- exiting
11月 27 09:56:37 localhost.localdomain systemd[1]: Failed to start DHCPv4 Server Daemon.
11月 27 09:56:37 localhost.localdomain dhcpd[78463]: 
11月 27 09:56:37 localhost.localdomain dhcpd[78463]: If you think you have received this message due to a bug rather
11月 27 09:56:37 localhost.localdomain dhcpd[78463]: than a configuration issue please read the section on submitting
11月 27 09:56:37 localhost.localdomain dhcpd[78463]: bugs on either our web page at www.isc.org or in the README file
11月 27 09:56:37 localhost.localdomain dhcpd[78463]: before submitting a bug.  These pages explain the proper
11月 27 09:56:37 localhost.localdomain dhcpd[78463]: process and the information we find helpful for debugging.
11月 27 09:56:37 localhost.localdomain dhcpd[78463]: 
11月 27 09:56:37 localhost.localdomain dhcpd[78463]: exiting.
lines 1-18/18 (END)

于是打开linux日志,定位到刚刚的错误信息:

Nov 27 09:56:37 localhost systemd[1]: Starting DHCPv4 Server Daemon...
Nov 27 09:56:37 localhost dhcpd[78463]: Internet Systems Consortium DHCP Server 4.3.6
Nov 27 09:56:37 localhost dhcpd[78463]: Copyright 2004-2017 Internet Systems Consortium.
Nov 27 09:56:37 localhost systemd[1]: dhcpd.service: Main process exited, code=exited, status=1/FAILURE
Nov 27 09:56:37 localhost dhcpd[78463]: All rights reserved.
Nov 27 09:56:37 localhost systemd[1]: dhcpd.service: Failed with result 'exit-code'.
Nov 27 09:56:37 localhost dhcpd[78463]: For info, please visit https://www.isc.org/software/dhcp/
Nov 27 09:56:37 localhost dhcpd[78463]: /etc/dhcp/dhcpd.conf line 5: subnet 10.3.45.37 netmask 255.255.0.0: bad subnet number/mask combination.
Nov 27 09:56:37 localhost dhcpd[78463]: 
Nov 27 09:56:37 localhost dhcpd[78463]: ^
Nov 27 09:56:37 localhost dhcpd[78463]: Configuration file errors encountered -- exiting
Nov 27 09:56:37 localhost systemd[1]: Failed to start DHCPv4 Server Daemon.
Nov 27 09:56:37 localhost dhcpd[78463]: 
Nov 27 09:56:37 localhost dhcpd[78463]: If you think you have received this message due to a bug rather
Nov 27 09:56:37 localhost audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=dhcpd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Nov 27 09:56:37 localhost dhcpd[78463]: than a configuration issue please read the section on submitting
Nov 27 09:56:37 localhost dhcpd[78463]: bugs on either our web page at www.isc.org or in the README file
Nov 27 09:56:37 localhost dhcpd[78463]: before submitting a bug.  These pages explain the proper
Nov 27 09:56:37 localhost dhcpd[78463]: process and the information we find helpful for debugging.
Nov 27 09:56:37 localhost dhcpd[78463]: 
Nov 27 09:56:37 localhost dhcpd[78463]: exiting.
Nov 27 09:56:37 localhost [/bin/bash]: [systemctl restart dhcpd] return code=[1], execute failed by [root(uid=0)] from [pts/8 (:3.0)]
Nov 27 09:58:23 localhost [/bin/bash]: [systemctl status dhcpd] return code=[130], execute failed by [root(uid=0)] from [pts/8 (:3.0)]
Nov 27 09:58:31 localhost [/bin/bash]: [vim /etc/dhcp/dhcpd.conf] return code=[0], execute success by [root(uid=0)] from [pts/8 (:3.0)]

很明显看到是由于配置文件中的subnet不正确导致。
遂重新编辑:vim /etc/dhcp/dhcpd.conf

在这里插入代码片#ddns-update-style none;
#authoritative;
log-facility local7;

subnet 10.3.45.37  netmask 255.255.0.0
{
  range 10.3.45.101  10.3.45.200;                               ##地址池 
  option domain-name-servers  223.5.5.5;                        ##DNS服务器地址
  option domain-name "class.com";                               ##域名
  option routers 10.3.0.2;                                      ##默认路由
  option broadcast-address 10.3.45.255;                          ##广播地址
  default-lease-time 300;                                       ##默认租约时间 
  max-lease-time 7200;                                          ##最大租约时间 
}

~   

把subnet 10.3.45.37 netmask 255.255.0.0
改成subnet 10.3.45.0 netmask 255.255.255.0
就OK了,重启一下,大功告成~

[root@localhost sambauser]# systemctl restart dhcpd
[root@localhost sambauser]# systemctl status dhcpd
● dhcpd.service - DHCPv4 Server Daemon
   Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-11-27 10:07:59 CST; 1min 9s ago
     Docs: man:dhcpd(8)
           man:dhcpd.conf(5)
 Main PID: 78865 (dhcpd)
   Status: "Dispatching packets..."
    Tasks: 1
   Memory: 5.0M
   CGroup: /system.slice/dhcpd.service
           └─78865 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid

11月 27 10:07:59 localhost.localdomain dhcpd[78865]: 
11月 27 10:07:59 localhost.localdomain dhcpd[78865]: 
11月 27 10:07:59 localhost.localdomain dhcpd[78865]: No subnet declaration for eth0 (no IPv4 addresses).
11月 27 10:07:59 localhost.localdomain dhcpd[78865]: ** Ignoring requests on eth0.  If this is not what
11月 27 10:07:59 localhost.localdomain dhcpd[78865]:    you want, please write a subnet declaration
11月 27 10:07:59 localhost.localdomain dhcpd[78865]:    in your dhcpd.conf file for the network segment
11月 27 10:07:59 localhost.localdomain dhcpd[78865]:    to which interface eth0 is attached. **
11月 27 10:07:59 localhost.localdomain dhcpd[78865]: 
11月 27 10:07:59 localhost.localdomain dhcpd[78865]: Sending on   Socket/fallback/fallback-net
11月 27 10:07:59 localhost.localdomain dhcpd[78865]: Server starting service.
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值