CentOS 7 DHCP 服务器无法启动(无法在指定端口上启用)

CentOS 7 DHCP 服务器无法启动(无法在指定端口上启用)

我有一台 Cent0S 7 miniPC,带有无线和有线网络端口。无线端口 (wlp3s0) 作为 DHCP 客户端连接,地址为 192.168.10.X,并具有 DNS 解析功能。

我正在尝试将有线端口 (enp2s0) 设置为具有 192.168.100.X 地址的私有子网的 DHCP 服务器。迷你电脑将连接到网络交换机,该交换机将连接其他客户端设备进行测试。

我按照 RedHat 的指示这里完全正确。

/etc/systemd/system/dhcpd.service的如下:

[Unit]
Description=DHCPv4 Server Daemon
Documentation=man:dhcpd(8) man:dhcpd.conf(5)
Wants=network-online.target
After=network-online.target
After=time-sync.target

[Service]
Type=notify
ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid enp2s0

[Install]
WantedBy=multi-user.target

我的/etc/dhcp/dhcpd.conf如下:

default-lease-time 600;
max-lease-time 7200;
authoritative;

subnet 192.168.100.0 netmask 255.255.255.0 {
    option routers                  192.168.100.1;
    option subnet-mask              255.255.255.0;
    option broadcast-address        192.168.100.255;
    range 192.168.100.10 192.168.100.100;
}

当我去配置并启动服务时:

sudo systemctl --system daemon-reload
sudo systemctl restart dhcpd.service

我得到这个/var/log/messages

localhost systemd: Starting DHCPv4 Server Daemon...
localhost dhcpd: Internet Systems Consortium DHCP Server 4.2.5
localhost dhcpd: Copyright 2004-2013 Internet Systems Consortium.
localhost dhcpd: All rights reserved.
localhost dhcpd: For info, please visit https://www.isc.org/software/dhcp/
localhost dhcpd: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
localhost dhcpd: Wrote 0 leases to leases file.
localhost dhcpd: 
localhost dhcpd: No subnet declaration for enp2s0 (no IPv4 addresses).
localhost dhcpd: ** Ignoring requests on enp2s0.  If this is not what
localhost dhcpd:   you want, please write a subnet declaration
localhost dhcpd:   in your dhcpd.conf file for the network segment
localhost dhcpd:   to which interface enp2s0 is attached. **
localhost dhcpd: 
localhost dhcpd: 
localhost dhcpd: Not configured to listen on any interfaces!
localhost dhcpd: 
localhost dhcpd: This version of ISC DHCP is based on the release available
localhost dhcpd: on ftp.isc.org.  Features have been added and other changes
localhost dhcpd: have been made to the base software release in order to make
localhost dhcpd: it work better with this distribution.
localhost dhcpd: 
localhost dhcpd: Please report for this software via the CentOS Bugs Database:
localhost dhcpd:    http://bugs.centos.org/
localhost dhcpd: 
localhost dhcpd: exiting.
localhost systemd: dhcpd.service: main process exited, code=exited, status=1/FAILURE
localhost systemd: Failed to start DHCPv4 Server Daemon.
localhost systemd: Unit dhcpd.service entered failed state.
localhost systemd: dhcpd.service failed.

知道这里出了什么问题吗?

谢谢。

答案1

您的第二个接口 (enp2s0) 没有 IP 地址。使用来自定义网络的地址设置它 -ip addr add 192.168.100.1/24 dev enp2s0然后再次运行 dhcp 服务。该接口的 IP 地址必须是静态的。

答案2

在 /etc/sysconfig/network-scripts/ifcfg-enp2s0 中配置 enp2s0 接口的静态 IP 地址 192.168.100.1。

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Using_the_Command_Line_Interface.html

相关内容