运维过程中,经常会出现需要确认网卡连接状态的情况,除了可以去现场摸线排查,还可以通过网络设备和服务器的ARP对应关系确认,当然也可以仅从服务器端进行确认,以下就简单介绍从服务器端确认网卡物理链路连接状态的几种方法
1.通过带外确认网卡状态
登陆ILO或者IDRAC之类页面,通过查看网卡状态可以确认
HPE相关设备登陆ILO
DELL相关设备登陆IDRAC
2.通过操作系统确认网卡状态
2.1Windows Server
直接查看网卡状态
也可以通过服务器管理,确认绑定对应关系
2.2RHEL 7
可以通过以下命令确认网卡当前状态(链路状态正常的端口会有数据包经过,关注bytes和packets)
$ cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
eno1: 591923457589 3738583108 0 0 0 0 0 11448856 1679661440973 3527025712 0 0 0 0 0 0
eno2: 1566607787 16157364 0 0 0 0 0 11464336 1922230323 4093529 0 0 0 0 0 0
eno3: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
eno4: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
bond0: 593490065376 3754740472 0 500 0 0 0 22913192 1681583671296 3531119241 0 0 0 0 0 0
lo: 2542909329956 2849939732 0 0 0 0 0 0 2542909329956 2849939732 0 0 0 0 0 0
virbr0-nic: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
virbr0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
通过ethtool再次确认网卡连接状态(关注最后Link detected状态为yes)
ethtool eno1
Settings for eno1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Link partner advertised pause frame use: Symmetric Receive-only
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: on
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x000000ff (255)
drv probe link timer ifdown ifup rx_err tx_err
Link detected: yes
做过绑定的可以通过以下命令确认网卡绑定关系(主要关注MII Status为UP)
$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eno1 (primary_reselect always)
Currently Active Slave: eno1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eno1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 20:xx:xx:xx:xx:2c
Slave queue ID: 0
Slave Interface: eno2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 20:xx:xx:xx:xx:2d
Slave queue ID: 0
2.3 虚拟化宿主机
登陆VC,选择对应宿主机,点击配置→查看物理适配器→右侧实际速率可以体现链路连接状态,另外右侧可以查看到端口和虚拟交换机对应关系