DHCP 服務異常導致終端無法獲取 IP、IP 衝突、租約異常,是網管高頻工單來源。本文梳理廠商通用 (Huawei/H3C/Cisco/Ruijie) 的 三階段標準化排查體系:物理鏈路通斷 → 服務器配置合規 → 地址池可用性,附關鍵命令、判斷邏輯、常見坑點與自動化腳本思路,將故障定位時間從 30 分鐘壓縮至 5 分鐘內。
192.168.1.100/24,網關 192.168.1.1)。ping 192.168.1.1 通 → 物理鏈路、VLAN、端口模式、生成樹均正常。bootp or dhcp,確認客戶端發送 DHCP Discover、服務器回應 DHCP Offer。# 華為/H3C
dhcp enable
debugging dhcp server all
terminal debugging
terminal monitor
# Cisco IOS
service dhcp
debug ip dhcp server events
debug ip dhcp server packets
觀察是否收到 Discover,若無 → 定位 L2 隔離 (VLAN 錯誤、Port Isolation、ACL 攔截、中綠設備不轉發廣播)。
| 配置項 | 命令示例 (華為/H3C) | 判斷標準 |
|---|---|---|
| 全局啟用 | dhcp enable | 必須開啟 |
| 地址池存在 | display dhcp server tree all | 顯示 pool-name、network、gateway、dns |
| 地址池網段匹配 | network 192.168.1.0 mask 255.255.255.0 | 與接口 IP (GigabitEthernet1/0/0) 同網段 |
| 接口綁定全局池 | dhcp select global (接口視圖) 或 dhcp select global all (系統視圖) | 客戶端所在接口必須引用正確地址池 |
| 網關/DNS/租期 | gateway-list 192.168.1.1dns-list 114.114.114.114lease day 1 | 與網絡規劃一致 |
192.168.1.1/24,池卻配 192.168.2.0/24 → 客戶端無法獲取 IP。dhcp select global → 服務器不處理該接口請求。dhcp relay server-group 指向服務器 IP。dhcp server ping packet 0 或 ping timeout 0 → 直接分發未探測 IP,極易衝突。# 1. 可用空閒地址
display dhcp server free-ip
# 2. 過期地址 (租期過、客戶端未續租)
display dhcp server expired pool pool-name
# 3. 沖突地址 (雙設備同 IP)
display dhcp server conflict all
reset dhcp server expired pool pool-name 回收。reset dhcp server conflict ip-address x.x.x.x 釋放。def dhcp_health_check(device):
cmds = [
"display dhcp server free-ip",
"display dhcp server expired pool all",
"display dhcp server conflict all",
"display dhcp server statistics"
]
output = device.send_commands(cmds)
# 解析輸出:free_ip < 阈值 → 告警;conflict > 0 → 工單;expired > 100 → 擴容建議
return parse_and_alert(output)
一 Ping 通、二 看配、三 查池
Ping 通網關排除物理;
看配置啟用、池網段、接口綁定;
查空閒、過期、沖突,按策略釋放擴容。
全程留痕、腳本巡檢、標準化 SOP,故障不再慌。