无法启动 isc-dhcp-server,因为出现错误:未配置为侦听任何接口

无法启动 isc-dhcp-server,因为出现错误:未配置为侦听任何接口

我尝试使用 hostapd 和 isc-dhcpd 设置 wifi 接入点,但 dhcp 服务器不工作。conf 文件与我在本教程中找到的相同:[Hostapd:创建虚拟 Wifi 接入点的 Linux 方式][1] !!!! 好吧,我想除了对我已经阅读的文档没有用的提示之外,我不会得到任何帮助...!!!!

这是我想使用命令“systemctl start isc-dhcp-server.service”或“service isc-dhcp-server start”启动它时收到的错误消息

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.

这是命令“systemctl status isc-dhcp-server.service”的输出:

> root@l0calh0st:~# systemctl status isc-dhcp-server.service ●
> isc-dhcp-server.service - LSB: DHCP server    Loaded: loaded
> (/etc/init.d/isc-dhcp-server; generated; vendor preset: disabled)   
> Active: failed (Result: exit-code) since Tue 2018-01-09 18:23:07 CET;
> 3s ago
>      Docs: man:systemd-sysv-generator(8)   Process: 3831 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited,
> status=1/FAILURE)
> 
>     Jan 09 18:23:05 l0calh0st dhcpd[3842]: bugs on either our web page at www.isc.org or in the README file
>     Jan 09 18:23:05 l0calh0st dhcpd[3842]: before submitting a bug.  These pages explain the proper
>     Jan 09 18:23:05 l0calh0st dhcpd[3842]: process and the information we find helpful for debugging..
>     Jan 09 18:23:05 l0calh0st dhcpd[3842]: 
>     Jan 09 18:23:05 l0calh0st dhcpd[3842]: exiting.
>     Jan 09 18:23:07 l0calh0st isc-dhcp-server[3831]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ... failed!
>     Jan 09 18:23:07 l0calh0st isc-dhcp-server[3831]:  failed!
>     Jan 09 18:23:07 l0calh0st systemd[1]: isc-dhcp-server.service: Control process exited, code=exited status=1
>     Jan 09 18:23:07 l0calh0st systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
>     Jan 09 18:23:07 l0calh0st systemd[1]: Failed to start LSB: DHCP server.

这是命令“journalctl -xe”的输出

root@l0calh0st:~# journalctl -xe
Jan 09 19:44:42 l0calh0st dhcpd[4212]: 
Jan 09 19:44:42 l0calh0st dhcpd[4212]: 
Jan 09 19:44:42 l0calh0st dhcpd[4212]: Not configured to listen on any interfaces!
Jan 09 19:44:42 l0calh0st dhcpd[4212]: 
Jan 09 19:44:42 l0calh0st dhcpd[4212]: If you think you have received this message due to a bug rather
Jan 09 19:44:42 l0calh0st dhcpd[4212]: than a configuration issue please read the section on submitting
Jan 09 19:44:42 l0calh0st dhcpd[4212]: bugs on either our web page at www.isc.org or in the README file
Jan 09 19:44:42 l0calh0st dhcpd[4212]: before submitting a bug.  These pages explain the proper
Jan 09 19:44:42 l0calh0st dhcpd[4212]: process and the information we find helpful for debugging..
Jan 09 19:44:42 l0calh0st dhcpd[4212]: 
Jan 09 19:44:42 l0calh0st dhcpd[4212]: exiting.
Jan 09 19:44:44 l0calh0st isc-dhcp-server[4201]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ... failed!
Jan 09 19:44:44 l0calh0st isc-dhcp-server[4201]:  failed!
Jan 09 19:44:44 l0calh0st systemd[1]: isc-dhcp-server.service: Control process exited, code=exited status=1
Jan 09 19:44:44 l0calh0st systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Jan 09 19:44:44 l0calh0st systemd[1]: Failed to start LSB: DHCP server.
-- Subject: Unit isc-dhcp-server.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit isc-dhcp-server.service has failed.
-- 
-- The result is RESULT.

这是 etc/dhcp/dhcpd.conf 文件:

ddns-update-style none;
ignore client-updates;
authoritative;
option local-wpad code 252 = text;

subnet
10.0.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers
10.0.0.1;
# --- Netmask
option subnet-mask
255.255.255.0;
# --- Broadcast Address
option broadcast-address
10.0.0.255;
# --- Domain name servers, tells the clients which DNS servers to use.
option domain-name-servers
10.0.0.1, 8.8.8.8, 8.8.4.4;
option time-offset
0;
range 10.0.0.3 10.0.0.13;
default-lease-time 1209600;
max-lease-time 1814400;
}

这是 /etc/default/isc-dhcp-server 文件:

# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.pid

# Additional options to start dhcpd with.
#   Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#   Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="wlan0"
INTERFACESv6=""

这是 /etc/network/interfaces 文件:(我不知道这是否重要)

    # This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback


auto wlan0
iface wlan0 inet static
  address 10.0.0.14
  netmask 255.255.255.0

ifconfig 的输出:

root@l0calh0st:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.101  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 2003:50:ad02:a21:d455:ca81:501e:727a  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::da92:2698:1cc8:40d  prefixlen 64  scopeid 0x20<link>
        ether 40:8d:5c:52:43:f4  txqueuelen 1000  (Ethernet)
        RX packets 4908  bytes 2441138 (2.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5464  bytes 822466 (803.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xdf200000-df220000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Lokale Schleife)
        RX packets 188  bytes 14388 (14.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 188  bytes 14388 (14.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 36:58:48:6a:7b:16  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

答案1

dhcpd 需要 2 个文件才能工作:
/etc/default/dhcpd.conf-- 定义接口(您缺少的)

/etc/dhcp/dhcpd.conf-- 您已经完成的文件

的内容/etc/default/dhcpd.conf看起来应该是这样的:

# /etc/default/dhcpd.conf
INTERFACES="eth0"

答案2

您应该首先设置接口并在其上配置 DHCP 服务器 IP。转到 /etc/network/interfaces(如果您运行的是版本 17 或更早版本)或者您可以使用 netplan(适用于 18.04)。其余所有配置都是正确的。

答案3

正如建议的那样NeoGeek 的回答,我必须将接口添加到/etc/default/isc-dhcp-server。(在我的情况下为“enp4s0”,如图所示ip addr

INTERFACESv4="enp4s0"

systemctl restart isc-dhcp-serversystemctl stop isc-dhcp-server不起作用。该dhcpd进程仍在运行,如所示ps ax | grep dhcpd,并且还必须删除 pid 文件。

因此,将接口名称添加到默认文件后,我必须:

killall dhcpd
rm /var/run/dhcpd.pid 
systemctl start isc-dhcp-server.service 

那是在 Debian 11.5 上。

答案4

您应该使用journalctl -xe(如错误消息所建议的)来获取有关错误实际是什么的更多详细信息。

您可能需要四处寻找才能找到它。或者您可以journalctl -f在一个终端中运行并重新启动服务,该服务应写入日志的末尾并在另一个终端中可见。


1 月 9 日 19:44:42 l0calh0st dhcpd[4212]: 未配置为监听任何接口!

^^^ 这就是你的问题。

相关内容