網吧環境:電腦配 10/100Mbps 自適應網卡,交換機亦為全雙工 10/100Mbps。網路連線正常,但上網速度時快時慢、不穩定。
自動協商失敗:網卡與交換機雙方協商速度/雙工模式時,因線材品質、晶片相容性、電磁干擾等原因,導致協商結果不穩定,頻繁在 10M/半雙工與 100M/全雙工間切換,造成大量重傳與延遲波動。
# 查看當前協商狀態
ethtool eth0
# 輸出關鍵:Speed: 100Mb/s, Duplex: Full, Auto-negotiation: on
# 強制設定 100M 全雙工,關閉自動協商
ethtool -s eth0 speed 100 duplex full autoneg off
# 永久生效(寫入網卡配置檔)
# CentOS/RHEL: /etc/sysconfig/network-scripts/ifcfg-eth0
ETHTOOL_OPTS="speed 100 duplex full autoneg off"
# Ubuntu/Debian: /etc/network/interfaces
post-up ethtool -s eth0 speed 100 duplex full autoneg off
ethtool eth0 顯示 Speed: 100Mb/s, Duplex: Full, Auto-negotiation: offethtool 狀態,異常告警「自動協商」雖是標準,但在百兆老舊環境中頻繁失效。觀察交換機指示燈跳變是快速判斷的關鍵徵兆,強制固定速雙工即可徹底根治時快時慢問題。