Dhcp

CentOS 7 DHCP 伺服器無法啟動(不會在指定埠上啟用)

  • August 14, 2016

我有一台帶有無線和有線網路埠的 Cent0S 7 miniPC。無線埠 (wlp3s0) 作為 DHCP 客戶端連接,地址為 192.168.10.X,並具有 DNS 解析。

我正在嘗試將有線埠(enp2s0)設置為具有 192.168.100.X 定址的私有子網的 DHCP 伺服器。miniPC 將連接到網路交換機,該交換機將連接其他客戶端設備進行測試。

我按照從 RedHat 到 T 恤的指示

/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.

知道這裡出了什麼問題嗎?

謝謝。

您的第二個介面 (enp2s0) 沒有 IP 地址。使用已定義網路中的地址設置他 -ip addr add 192.168.100.1/24 dev enp2s0然後再次執行 dhcp 服務。該介面的 IP 地址必須是靜態的。

在 /etc/sysconfig/network-scripts/ifcfg-enp2s0 中使用靜態 IP 地址 192.168.100.1 配置 enp2s0 介面。

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

引用自:https://serverfault.com/questions/796776