最近公司的機器存在網絡問題, 部分網絡總是不通, 比較奇怪. 最近一直想處理好.
第一步: 先查看網口的設備信息
可以使用
ip link show
可以講網口信息都展示出來.
一般情況下 NO-CARRIER 的信息就意味着麼有插入網線. 或許可以繼續進行驗證
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp39s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether b4:05:5d:b3:b1:fc brd ff:ff:ff:ff:ff:ff 3: enp39s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP mode DEFAULT group default qlen 1000 link/ether b4:05:5d:b3:b1:fd brd ff:ff:ff:ff:ff:ff 4: enp39s0f2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000 link/ether b4:05:5d:b3:b1:fe brd ff:ff:ff:ff:ff:ff 5: enp39s0f3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000 link/ether b4:05:5d:b3:b1:ff brd ff:ff:ff:ff:ff:ff
這裏需要說明一下網卡的命名問題
CentOS6 以及之前的命令 都是使用 eth0 eth1 這樣類似的命名 很簡單, 也不會出問題 CentOS7 之後的網卡, 虛擬機裏面貌似都會是 ens192 類似的網口名字 s 應該是 插座的意思. 如果是服務器 如果是板載的網卡 一把你是 ens開頭. 如果是PCI-e插入的網卡一般是 enp 開頭 p 應該是pluggable 的部分含義. 有時候需要統一網卡名字,便於處理. 今天暫時不考慮這一塊的操作.
第二步: 先確認網口是否連接網線.
使用的方式爲 ethtool device_name 的方式.
方法也很簡單. 結果裏面有一個 Speed 以及 Duplex 還有 Link Detected
根據是否有值來判斷是否可用.
[root@testsvr113 network-scripts]# ethtool enp39s0f2 Settings for enp39s0f2: Supported ports: [ ] Supported link modes: 1000baseT/Full Supported pause frame use: Symmetric Receive-only Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Speed: Unknown! Duplex: Unknown! (255) Auto-negotiation: off Port: Other PHYAD: 0 Transceiver: internal Supports Wake-on: g Wake-on: g Current message level: 0x00000007 (7) drv probe link Link detected: no [root@testsvr113 network-scripts]# ethtool enp39s0f1 Settings for enp39s0f1: Supported ports: [ TP ] Supported link modes: 1000baseT/Full Supported pause frame use: Symmetric Receive-only Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Speed: 1000Mb/s Duplex: Full Auto-negotiation: on Port: Twisted Pair PHYAD: 0 Transceiver: internal MDI-X: Unknown Supports Wake-on: g Wake-on: g Current message level: 0x00000007 (7) drv probe link Link detected: yes
第三部分: 設置IP地址進行驗證
建議可以使用 nmtui 或者是 cockpit 的方式進行IP地址的設置
其實改名的話 可以在nmtui 裏面講網卡名字改掉.
注意設置完地址 需要外部進行ping 連接 如果機器設置的IP段與實際的IP地址段不一致, 那麼是無法使用的.