Skip to content

Nuface Blog

隨意隨手記 Casual Notes

Menu
  • Home
  • About
  • Services
  • Blog
  • Contact
  • Privacy Policy
  • Login
Menu

UniFi Switch 自動啟用 DHCP 的問題分析與解決實錄

Posted on 2025-11-052025-11-05 by Rico

設備環境:USW-Lite-8-PoE(v7.2.123、v8.x 測試) / UniFi Network Controller 9.5.21


📌 一、問題背景

在企業網路環境中,Switch 一般僅作為二層設備,不應主動發放 DHCP 位址。
然而,在升級 UniFi Switch 韌體到 8.x 版以後,筆者發現以下異常行為:

  1. Switch 在 Adopt 至 Controller 之後,偶爾會自動啟動內建 DHCP Server。
  2. 該 DHCP 服務會在 LAN 中放出 IP(通常是 192.168.1.x/24 範圍),造成網段衝突與使用者掉線。
  3. 當 Controller 偵測到衝突或 Switch 失聯後,設備會進入 Fallback 狀態 → 自動 Reset → 再次出現 DHCP,形成無限循環。

這個問題在 USW-Lite 8 PoE、USW-Flex Mini 等機種尤其明顯。
升級 8.x 韌體後,即使完成 Adopt,仍會不定期出現 DHCP 放送。


🔍 二、問題分析

1️⃣ 版本變化造成的差異

項目UniFi 7.xUniFi 8.x 之後
Provision 流程使用舊版 inform-based 管理改為 “UDAPI Provisioning”
Switch DHCP 模式僅於 Standalone 模式啟用可能在 Provision 失敗或落單時誤啟動
SSH 帳號管理預設 ubnt / 控制器可自訂Provision 後自動改為 Controller 統一帳密

當 8.x 版本的 Switch 在 Provision 過程中遇到逾時、認證中斷,系統會誤判為「Standalone」,重新啟用 DHCP 服務,導致網段混亂。


2️⃣ SSH 登入行為變化

  • 出廠狀態(未 Adopt)
    帳號密碼為 ubnt / ubnt,可直接 SSH 登入。
  • Adopt 後
    帳號會被 Controller 覆蓋,變成 Controller 設定的 SSH 帳密。
  • Forget 或 Provision 失敗後
    Switch 會回落成半管理狀態,但 SSH 登入仍被封鎖(控制器帳號已遺失)。

⚠️ 這就是為什麼 Reset 後短時間內能用 ubnt/ubnt 登入,
但一旦重新 Adopt 或 Provision,就立即失效。


🧰 三、實際排錯與驗證流程

(1) 停止 DHCP Server

SSH 進入 Switch:

ssh <controller_ssh_username>@<switch_ip>
ps | grep udhcpd
killall udhcpd
pgrep udhcpd    # 確認已無進程

若沒有任何 udhcpd 進程,代表 DHCP 已關閉。


(2) 從 Controller 側確認

在 Settings → Networks 頁面中,
若沒有 Gateway 設定(顯示「Third-party Gateway」),則 Controller 本身不會開 DHCP。

因此出現 DHCP 的唯一來源是 Switch。


(3) 驗證網路中是否還有 DHCP

在主控主機上:

sudo tcpdump -n -i eth0 port 67 or port 68

若無回應,即代表 DHCP 流量已消失,網路恢復正常。


🧩 四、穩定版本與維運策略

筆者實測結果如下:

Switch 韌體版本狀態備註
7.2.123✅ 穩定無 DHCP 問題建議企業固定此版本
8.0.x ~ 8.1.x❌ 存在 DHCP Fallback bug官方未完全修正
9.3.x 以上⚠️ 部分機型改善,但建議先測試再量產

在 7.x 韌體下,USW-Lite 系列運作穩定、Provision 正常,
並與 UniFi Network Controller 7.x ~ 9.x 完全相容。


⚙️ 五、建議設定

1️⃣ 固定韌體版本

  • 關閉自動升級:
    Settings → System → Updates → Disable automatic firmware updates
  • 或在設備頁面 → Config → Firmware → Lock Version 7.2.123

2️⃣ 控制 SSH 管理權

Settings → System → Device SSH Authentication
→ 改為 Custom per device,設定專用管理帳密。

3️⃣ 啟用 Rogue DHCP Server Detection

Settings → Networks → Global Switch Settings → 勾選「Rogue DHCP Server Detection」
控制器將即時監控任何新的 DHCP 來源。

4️⃣ 定期備份 Controller 設定

匯出路徑:
/opt/unifi/config/data/backup/autobackup


🧭 六、長期建議與觀察

  1. 維持 7.x 為主版本運行,避免升級至不穩定的 8.x。
  2. 若有多型號 Switch,可分群管理(新機用新版本,舊機固定 7.x)。
  3. 等官方 9.6.x 釋出後,再於測試環境觀察 DHCP fallback 是否完全修復。
  4. 若需要在同一控制器中混合多韌體版本,可透過 YAML 或 API 建立升級白名單策略。

✅ 七、總結

項目狀態備註
問題來源UniFi 8.x 新 Provision 模組誤啟 DHCP已確認
暫時解法固定 7.2.123 版本運行最穩定
長期方案升 9.x 並驗證 DHCP 修復狀況需測試
SSH 登入Adopt 後密碼由 Controller 管理正常行為
維運建議關自動升級 + 開 Rogue DHCP 檢測最安全

💬 作者註記

實務上,對企業網管環境而言,「穩定」比「版本新」更重要。
經過多次實測,UniFi Switch 韌體 7.2.123 能夠提供完整 VLAN、PoE、STP、Rogue DHCP 偵測功能,
且不會誤啟 DHCP。
因此,固定版本、控制升級節奏,仍是目前最務實的做法。


Recent Posts

  • Postfix + Let’s Encrypt + BIND9 + DANE Fully Automated TLSA Update Guide
  • Postfix + Let’s Encrypt + BIND9 + DANE TLSA 指紋自動更新完整教學
  • Deploying DANE in Postfix
  • 如何在 Postfix 中部署 DANE
  • DANE: DNSSEC-Based TLS Protection

Recent Comments

  1. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on High Availability Architecture, Failover, GeoDNS, Monitoring, and Email Abuse Automation (SOAR)
  2. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on MariaDB + PostfixAdmin: The Core of Virtual Domain & Mailbox Management
  3. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Daily Operations, Monitoring, and Performance Tuning for an Enterprise Mail System
  4. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Final Chapter: Complete Troubleshooting Guide & Frequently Asked Questions (FAQ)
  5. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Network Architecture, DNS Configuration, TLS Design, and Postfix/Dovecot SNI Explained

Archives

  • December 2025
  • November 2025
  • October 2025

Categories

  • AI
  • Apache
  • Cybersecurity
  • Database
  • DNS
  • Docker
  • Fail2Ban
  • FileSystem
  • Firewall
  • Linux
  • LLM
  • Mail
  • N8N
  • OpenLdap
  • OPNsense
  • PHP
  • QoS
  • Samba
  • Switch
  • Virtualization
  • VPN
  • WordPress
© 2025 Nuface Blog | Powered by Superbs Personal Blog theme