我刚刚在服务器上设置了 isc-dhcp。我甚至设置了正确的接口。但 dhcp 服务器仍然无法启动。Not configured to listen on any interfaces!
系统日志中显示。当我尝试时,dhcpd -t /etc/dhcp/dhcpd.conf
它给出了此错误:/etc/dhcp/dhcpd.conf: interface name too long (is 20
这是我的 dhcpd.conf:
ddns-update-style none;
option domain-name "thpi";
option domain-name-servers 208.67.222.222, 208.67.220.220;
default-lease-time 86400;
max-lease-time 604800;
authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
subnet 10.0.0.0 netmask 255.255.255.0 {
## dhcp start and end IP range ##
range 10.0.0.20 10.0.0.90;
option subnet-mask 255.255.255.0; ## subnet
option broadcast-address 10.0.0.255; ## broadcast
option routers 10.0.0.1; ## router IP
host pc1 {
hardware ethernet 60:a4:4c:3d:76:fa;
fixed-address 10.0.0.100;
}
host lap1 {
hardware ethernet 6c:71:d9:1e:f3:4f;
fixed-address 10.0.0.150;
}
host thnote {
hardware ethernet d0:22:be:d3:be:e1;
fixed-address 10.0.0.200;
}
}
/etc/default/isc-dhcp-server
文件 :
# Defaults for isc-dhcp-server initscript
# sourced by /etc/init.d/isc-dhcp-server
# installed at /etc/default/isc-dhcp-server by the maintainer scripts
#
# This is a POSIX shell fragment
#
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPD_CONF=/etc/dhcp/dhcpd.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.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".
INTERFACES="eth0:0"
接口文件:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
auto eth0:0
iface eth0:0 inet static
name Lan
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
可能存在什么问题?
答案1
你的/etc/default/isc-dhcp-server
文件应该有
INTERFACES="eth0"
答案2
我遇到了同样的问题,在为我的接口分配 IP 地址后问题得到了解决
喜欢,
ifconfig eth0 192.168.1.100
答案3
我也遇到了同样的问题。对于 Ubuntu 20.04 1 LTS。我有两个 NIC,我只想使用其中一个通过 dhcp 向 LAN 上的客户端提供 IP。
我的修复方法是以下几种方法的组合。不过,我认为真正的修复方法是向 /etc/dhcp/dhcpd.conf 添加接口
/etc/dhcp/dhcpd.conf
was (broken):
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.2 192.168.0.99;
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 1.1.1.1, 1.0.0.1, 8.8.8.8;
}
changed to (added interface and it worked):
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;
subnet 192.168.0.0 netmask 255.255.255.0 {
interface enp6s0;
range 192.168.0.2 192.168.0.99;
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 1.1.1.1, 1.0.0.1, 8.8.8.8;
}
在进行 hack 时,我还更改了以下内容,但不确定现在是否需要这样做。显示完整性。
/etc/default/isc-dhcp-server
was:
INTERFACESv4=""
INTERFACESv6=""
changed to (the interface I want dhcp to use):
INTERFACESv4="enp6s0"
INTERFACESv6="enp6s0"
答案4
开始建立人际网络有两种方式
通过 /etc/network/interfaces
通过 NetworkManager
- 尽早开始
- 开始得晚
DHCPD 尝试在 1) 之后但在 2) 之前启动
如果 dhcpd 无法检测网络,请尝试方法 1)