要確認網路線有沒有插好、協商速率是多少,ethtool 是最直接的工具。
# ethtool em1
Settings for em1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Link detected: yes
重點看三個欄位:Speed 是協商後的速率、Duplex 是否為 Full、Link detected 是否為 yes。
對照一顆沒插線的埠:
# ethtool em2
Settings for em2:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Speed: Unknown!
Duplex: Unknown! (255)
Port: Twisted Pair
PHYAD: 2
Auto-negotiation: on
Link detected: no
Speed 與 Duplex 顯示 Unknown、Link detected 為 no,就是實體層沒有連上——可能是網路線沒插、對端交換機埠關閉或線材故障。
# /etc/init.d/network status Configured devices: lo em1 em2 em3 em4 p3p1 p3p2 Currently active devices: lo em1 port0 port1 vlan1 dummy1
Configured 是設定檔裡有定義的裝置,Currently active 是目前真正有 IP 並啟用的。兩者不一致通常代表某個介面 down 掉了。
其他常用參數:ethtool -i em1 看驅動與韌體版本、ethtool -S em1 看詳細統計(含 CRC 錯誤、丢包)、ethtool -k em1 查 offload 設定。若 Link detected 為 no 但確定已接線,可試 ethtool -r em1 重啟協商。