为什么安装后无法启动isc-dhcp-server?


13

我正在按照 教程将Linux安装在没有CD阅读器或USB启动功能的系统中。最终,我达到了必须安装的程度,isc-dhcp-server并且确实做到了。

Apt告诉我有一个部分安装的软件包。我跑步sudo apt-get install -f,得到以下信息:

Job for isc-dhcp-server.service failed. See 'systemctl status isc-dhcp server.service' and 'journalctl -xn' for details.
invoke-rc.d: initscript isc-dhcp-server, action "start" failed.
dpkg: error processing package isc-dhcp-server (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
isc-dhcp-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

如果我这样做,/etc/init.d/isc-dhcp-server start则提示由同一条消息的前两行组成。

来自的输出sudo systemctl status isc-dhcp-server

● isc-dhcp-server.service - LSB: DHCP server
   Loaded: loaded (/etc/init.d/isc-dhcp-server)
   Active: failed (Result: exit-code) since Fri 2014-12-12 13:19:25 CST; 2min 43s ago
  Process: 1677 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)

Dec 12 13:19:23 semplice dhcpd[1684]: you want, please write a subnet declaration
Dec 12 13:19:23 semplice dhcpd[1684]: in your dhcpd.conf file for the network segment
Dec 12 13:19:23 semplice dhcpd[1684]: to which interface eth0 is attached. **
Dec 12 13:19:23 semplice dhcpd[1684]: 
Dec 12 13:19:23 semplice dhcpd[1684]: 
Dec 12 13:19:25 semplice isc-dhcp-server[1677]: Starting ISC DHCP server: dhcpdcheck syslog for diagnostics. ... failed!
Dec 12 13:19:25 semplice isc-dhcp-server[1677]: failed!
Dec 12 13:19:25 semplice systemd[1]: isc-dhcp-server.service: control process exited, code=exited status=1
Dec 12 13:19:25 semplice systemd[1]: Failed to start LSB: DHCP server.
Dec 12 13:19:25 semplice systemd[1]: Unit isc-dhcp-server.service entered failed state.

来自的输出sudo journalctl -xn

-- Logs begin at Fri 2014-12-12 12:57:16 CST, end at Fri 2014-12-12 13:32:01 CST. --
Dec 12 13:31:58 semplice NetworkManager[505]: <info>   lease time 86400
Dec 12 13:31:58 semplice NetworkManager[505]: <info>   nameserver '192.168.1.254'
Dec 12 13:31:58 semplice NetworkManager[505]: <info>   domain name 'lan'
Dec 12 13:31:58 semplice dbus[518]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.ser
Dec 12 13:31:58 semplice dbus[518]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Dec 12 13:31:58 semplice nm-dispatcher[2194]: Dispatching action 'dhcp4-change' for wlan0
Dec 12 13:31:58 semplice dhclient[616]: bound to 192.168.1.65 -- renewal in 45 seconds.
Dec 12 13:31:58 semplice NetworkManager[505]: bound to 192.168.1.65 -- renewal in 45 seconds.
Dec 12 13:32:01 semplice sudo[2197]: alejandro : TTY=pts/0 ; PWD=/home/alejandro ; USER=root ; COMMAND=/bin/journalctl -xn
Dec 12 13:32:01 semplice sudo[2197]: pam_unix(sudo:session): session opened for user root by alejandro(uid=0)

是我的/etc/dhcp/dhcpd.config文件,仅是上述教程中示例的副本。

/var/log/syslog运行后立即从读取输出apt-get install -f

Dec 12 16:42:40 localhost dhclient: DHCPREQUEST on wlan0 to 192.168.1.254 port 67
Dec 12 16:42:40 localhost NetworkManager[505]: DHCPREQUEST on wlan0 to 192.168.1.254 port 67
Dec 12 16:42:40 localhost dhclient: DHCPACK from 192.168.1.254
Dec 12 16:42:40 localhost NetworkManager[505]: DHCPACK from 192.168.1.254
Dec 12 16:42:40 localhost NetworkManager[505]: <info> (wlan0): DHCPv4 state changed renew -> renew
Dec 12 16:42:40 localhost NetworkManager[505]: <info>   address 192.168.1.65
Dec 12 16:42:40 localhost NetworkManager[505]: <info>   plen 24 (255.255.255.0)
Dec 12 16:42:40 localhost NetworkManager[505]: <info>   gateway 192.168.1.254
Dec 12 16:42:40 localhost NetworkManager[505]: <info>   server identifier 192.168.1.254
Dec 12 16:42:40 localhost NetworkManager[505]: <info>   lease time 86400
Dec 12 16:42:40 localhost NetworkManager[505]: <info>   nameserver '192.168.1.254'
Dec 12 16:42:40 localhost NetworkManager[505]: <info>   domain name 'lan'
Dec 12 16:42:40 localhost dbus[518]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Dec 12 16:42:40 localhost dbus[518]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Dec 12 16:42:40 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for wlan0
Dec 12 16:42:41 localhost dhclient: bound to 192.168.1.65 -- renewal in 52 seconds.
Dec 12 16:42:41 localhost NetworkManager[505]: bound to 192.168.1.65 -- renewal in 52 seconds.
Dec 12 16:43:32 localhost dhclient: DHCPREQUEST on wlan0 to 192.168.1.254 port 67
Dec 12 16:43:32 localhost NetworkManager[505]: DHCPREQUEST on wlan0 to 192.168.1.254 port 67
Dec 12 16:43:32 localhost dhclient: DHCPACK from 192.168.1.254
Dec 12 16:43:32 localhost NetworkManager[505]: DHCPACK from 192.168.1.254
Dec 12 16:43:32 localhost NetworkManager[505]: <info> (wlan0): DHCPv4 state changed renew -> renew
Dec 12 16:43:32 localhost NetworkManager[505]: <info>   address 192.168.1.65
Dec 12 16:43:32 localhost NetworkManager[505]: <info>   plen 24 (255.255.255.0)
Dec 12 16:43:32 localhost NetworkManager[505]: <info>   gateway 192.168.1.254
Dec 12 16:43:32 localhost NetworkManager[505]: <info>   server identifier 192.168.1.254
Dec 12 16:43:32 localhost NetworkManager[505]: <info>   lease time 86400
Dec 12 16:43:32 localhost NetworkManager[505]: <info>   nameserver '192.168.1.254'
Dec 12 16:43:32 localhost NetworkManager[505]: <info>   domain name 'lan'
Dec 12 16:43:32 localhost dbus[518]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Dec 12 16:43:32 localhost dbus[518]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Dec 12 16:43:32 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for wlan0
Dec 12 16:43:33 localhost dhclient: bound to 192.168.1.65 -- renewal in 54 seconds.
Dec 12 16:43:33 localhost NetworkManager[505]: bound to 192.168.1.65 -- renewal in 54 seconds.
Dec 12 16:43:40 localhost dhcpd: Internet Systems Consortium DHCP Server 4.3.1
Dec 12 16:43:40 localhost dhcpd: Copyright 2004-2014 Internet Systems Consortium.
Dec 12 16:43:40 localhost dhcpd: All rights reserved.
Dec 12 16:43:40 localhost dhcpd: For info, please visit https://www.isc.org/software/dhcp/
Dec 12 16:43:40 localhost dhcpd: Internet Systems Consortium DHCP Server 4.3.1
Dec 12 16:43:40 localhost dhcpd: Copyright 2004-2014 Internet Systems Consortium.
Dec 12 16:43:40 localhost dhcpd: All rights reserved.
Dec 12 16:43:40 localhost dhcpd: For info, please visit https://www.isc.org/software/dhcp/
Dec 12 16:43:40 localhost dhcpd: Wrote 0 deleted host decls to leases file.
Dec 12 16:43:40 localhost dhcpd: Wrote 0 new dynamic host decls to leases file.
Dec 12 16:43:40 localhost dhcpd: Wrote 0 leases to leases file.
Dec 12 16:43:40 localhost dhcpd: 
Dec 12 16:43:40 localhost dhcpd: No subnet declaration for eth0 (no IPv4 addresses).
Dec 12 16:43:40 localhost dhcpd: ** Ignoring requests on eth0.  If this is not what
Dec 12 16:43:40 localhost dhcpd:    you want, please write a subnet declaration
Dec 12 16:43:40 localhost dhcpd:    in your dhcpd.conf file for the network segment
Dec 12 16:43:40 localhost dhcpd:    to which interface eth0 is attached. **
Dec 12 16:43:40 localhost dhcpd: 
Dec 12 16:43:40 localhost dhcpd: 
Dec 12 16:43:40 localhost dhcpd: Not configured to listen on any interfaces!
Dec 12 16:43:40 localhost dhcpd: 
Dec 12 16:43:40 localhost dhcpd: If you think you have received this message due to a bug rather
Dec 12 16:43:40 localhost dhcpd: than a configuration issue please read the section on submitting
Dec 12 16:43:40 localhost dhcpd: bugs on either our web page at www.isc.org or in the README file
Dec 12 16:43:40 localhost dhcpd: before submitting a bug.  These pages explain the proper
Dec 12 16:43:40 localhost dhcpd: process and the information we find helpful for debugging..
Dec 12 16:43:40 localhost dhcpd: 
Dec 12 16:43:40 localhost dhcpd: exiting.
Dec 12 16:43:42 localhost isc-dhcp-server[5729]: Starting ISC DHCP server: dhcpdcheck syslog for diagnostics. ... failed!
Dec 12 16:43:42 localhost isc-dhcp-server[5729]: failed!
Dec 12 16:43:42 localhost systemd[1]: isc-dhcp-server.service: control process exited, code=exited status=1
Dec 12 16:43:42 localhost systemd[1]: Failed to start LSB: DHCP server.
Dec 12 16:43:42 localhost systemd[1]: Unit isc-dhcp-server.service entered failed state.

我应该隐藏我的IP地址吗?


1
您对这两行说了什么,即运行systemclt并查看日志?journalctl -xn尝试重新运行时,请发布生成的输出(可能需要对其进行sudo)apt-get install -f
Anthon 2014年

1
因此,dhcpd这还没有开始,在这里我们只收到其消息的结尾。似乎是在抱怨dhcpd.conf缺少一些必需的信息。您需要进一步追溯系统日志,才能查看来自的所有消息dhcpd。在传统系统上,日志应该位于/var/log/syslog,我不知道systemd是否将其弄乱了。
吉尔(Gilles)“所以,别再邪恶了”

Answers:


5

看来您的网络配置与dhcp.conf中的子网声明不匹配。确保已从10.10.1.0/24子网配置IP地址。您可以使用以下方法进行检查:

ip a

如果看不到这样的IP地址,请尝试将其添加到eth0中:

ip a a 10.10.1.200/24 dev eth0

之后,再次尝试修复软件包:

apt-get install -f

如果我是正确的,它应该安装该软件包并启动DHCP守护程序,并且您可能希望将此IP地址保留在/ etc / network / interfaces中


2
注意:ip a a代表ip address add
mxmlnkn

在我的rasp pi上出现此错误,无法启动服务,结果是ip中没有IP地址的命令输出。添加IP地址后,一切正常
Manny265 '18

@ Manny265您的评论没有任何意义;您运行DHCP的原因是它应该自动为您分配IP地址。
3:13

3

您的问题在这里:

Dec 12 16:43:40 localhost dhcpd: No subnet declaration for eth0 (no IPv4 addresses).
Dec 12 16:43:40 localhost dhcpd: ** Ignoring requests on eth0.  If this is not what
Dec 12 16:43:40 localhost dhcpd:    you want, please write a subnet declaration
Dec 12 16:43:40 localhost dhcpd:    in your dhcpd.conf file for the network segment
Dec 12 16:43:40 localhost dhcpd:    to which interface eth0 is attached. **
Dec 12 16:43:40 localhost dhcpd: 
Dec 12 16:43:40 localhost dhcpd: 
Dec 12 16:43:40 localhost dhcpd: Not configured to listen on any interfaces!
Dec 12 16:43:40 localhost dhcpd: 
Dec 12 16:43:40 localhost dhcpd: If you think you have received this message due to a bug rather
Dec 12 16:43:40 localhost dhcpd: than a configuration issue please read the section on submitting
Dec 12 16:43:40 localhost dhcpd: bugs on either our web page at www.isc.org or in the README file
Dec 12 16:43:40 localhost dhcpd: before submitting a bug.  These pages explain the proper
Dec 12 16:43:40 localhost dhcpd: process and the information we find helpful for debugging..
Dec 12 16:43:40 localhost dhcpd: 
Dec 12 16:43:40 localhost dhcpd: exiting.

您应该可以通过运行来重现错误消息dhcpd -t -cf /etc/dhcp/dhcpd.conf


我猜想您要与以太网上的其他主机共享无线Internet连接,如下面的拓扑图所示。

                            ↑
                            │ Uplink
                            │
               ┌────────────┴────────────┐
               │          wlan0          │
               │     192.168.1.65/24     │
               │                         │
               │        semplice         │
               │                         │
               │       10.10.1.1/24      │
               │          eth0           │
               └────────────┬────────────┘
                            │
     ┌──────────────┬───────┴────────┬──────────────┐
     │              │                │              │
   Host 1         Host 2           Host 3         Host 4
 10.10.1.21     10.10.1.22       10.10.1.23     10.10.1.24

我假设您服务器的地址为eth010.10.1.1。通过运行验证ip addr show dev eth0

然后,您必须配置 /etc/dhcp/dhcpd.conf为在eth0接口上分发地址。开箱即用,dhcpd配置为不响应任何内容,因为无意中运行的流氓DHCP服务器会通过将地址分发给任何请求主机的主机,从而对网络造成严重破坏。

在中/etc/dhcp/dhcpd.conf,您将需要一个类似以下的节:

subnet 10.10.1.0 netmask 255.255.255.0 {
    option subnet-mask        255.255.255.0;
    option broadcast-address  10.10.1.255;
    option routers            10.10.1.1;
    pool {
        range 10.10.1.21 10.10.1.254;
    }
}

......除了声明如authoritativedomain-namedomain-name-servers,和default-lease-time。(根据需要进行调整。只有您知道您的网络需要什么设置。)

另外,对于Debian,您需要进行编辑/etc/default/isc-dhcp-server以设置

INTERFACES="eth0"

这样服务器将侦听以太网端口。(您不想听wlan0;您的无线访问点负责将地址分发给无线客户端。)


2
他的问题是systemd忽略了旧init脚本的lsb init信息,该信息明确指出“#Required-Start:$ remote_fs $ network $ syslog”。与其等待网络单元,不如启动它,它将使dhcpd并行运行,甚至在此之前运行。
Florian Heigl

/etc/dhcp/dhcpd.conf应该使用有效的配置文件来解决此问题。isc-dhcp-server使用错误的dhcpd.conf配置,该服务将失败。
GAD3R '18 -10-10
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.