首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 更多程式語言 >> 程式設計綜合問答

Fedora DHCP 服務啟動失敗:介面未配置 IP 導致無監聽介面

     編輯:程式設計綜合問答

錯誤訊息分析

Not configured to listen on any interfaces!
No subnet declaration for restart (no IPv4 addresses).
** Ignoring requests on restart. If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface restart is attached. **

根本原因

DHCP 伺服器(dhcpd)啟動時掃描所有網路介面,發現沒有任何介面擁有 IPv4 位址且符合設定檔中的 subnet 宣告。錯誤訊息中的 restart 疑為介面名稱解析錯誤(實際介面名可能為 eth0、ens33 等),核心問題是伺服器網卡未設定靜態 IP。

解決步驟

1. 確認介面名稱與 IP 設定

ip addr show
# 或
ifconfig -a

確保目標介面(如 eth0)已配置 IPv4 位址與子網遮罩:

inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0

2. 設定靜態 IP(若尚未設定)

編輯 /etc/sysconfig/network-scripts/ifcfg-eth0:

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes

重啟網路服務:systemctl restart network

3. 修正 dhcpd.conf subnet 宣告

編輯 /etc/dhcp/dhcpd.conf,確保 subnet 區塊涵蓋伺服器 IP 所在網段:

subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.100 192.168.1.200;
    option routers 192.168.1.1;
    option domain-name-servers 8.8.8.8, 8.8.4.4;
    # 重要:authoritative 宣告
    authoritative;
}

4. 指定監聽介面(可選)

編輯 /etc/sysconfig/dhcpd:

DHCPDARGS=eth0

限制 dhcpd 僅監聽指定介面。

5. 防火牆與 SELinux

firewall-cmd --add-service=dhcp --permanent
firewall-cmd --reload
# SELinux 通常預設允許,若有問題檢查 audit.log

6. 啟動並驗證

systemctl enable dhcpd
systemctl start dhcpd
systemctl status dhcpd
journalctl -u dhcpd -f  # 即時查看日誌

常見誤區

  • 以為 DHCP 伺服器不需要 IP 位址(實際上需要介面 IP 判斷所屬 subnet)
  • subnet 宣告網段與介面實際 IP 不符
  • 多介面伺服器未指定 DHCPDARGS 導致監聽錯誤介面
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved