案例环境:有多张网卡,怎么去判断你的管理是接的哪一个呢?
在有多张网卡的服务器上,尤其是进行虚拟化管理(如PVE环境)时,准确定位管理网卡显得尤为重要。本文通过实际案例,展示如何逐步判断服务器的管理接口接在哪张网卡上,确保配置准确,避免错误操作导致管理系统失联。
一、查看PCI设备信息
首先,我们通过 lspci 查看所有网卡的PCI设备信息:
➜ ~ lspci
0000:03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
0000:04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
0000:05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
0000:06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
0000:0a:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 05)
虽然这里看到rev 04和rev 05,这里代表的是硬件版本号(Revision ID),但是我们架设我们两张卡都是这个类型,就没办法判断了哦。
二、查看网络配置
通过 ip addr 命令查看网络接口的状态和 IP 地址信息:
➜ ~ ip addr
6: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master vmbr0 state UP group default qlen 1000
link/ether c8:28:88:88:f8:38 brd ff:ff:ff:ff:ff:ff
altname enp10s0
7: vmbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether c8:28:88:88:f8:38 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.4/24 scope global vmbr0
valid_lft forever preferred_lft forever
inet6 288e:380:4848:f808:8828:a8f8:f838:8f88/64 scope global dynamic mngtmpaddr
valid_lft 44486sec preferred_lft 44486sec
inet6 fe80::ce28:aaff:fe34:ff3d/64 scope link
valid_lft forever preferred_lft forever
从这里可以看出,你的管理接口是vmbr0,它绑定了192.168.0.4/24的IP地址,物理网卡是eno1 作为 vmbr0 的下层接口,它的MAC地址是c8:28:88:88:f8:38,代表该网卡是服务器的管理接口。
三、查看PCI设备详细信息
通过 lspci -v 可以进一步查看网卡的详细信息:
➜ ~ lspci -v
0000:03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
Subsystem: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller
Flags: fast devsel, IRQ 16, IOMMU group 17
I/O ports at 6000
Memory at 86110000 (64-bit, non-prefetchable) [size=64K]
Memory at 86120000 (64-bit, non-prefetchable) [size=16K]
Expansion ROM at 86100000 [disabled] [size=64K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Capabilities: [70] Express Endpoint, MSI 01
Capabilities: [b0] MSI-X: Enable+ Count=32 Masked-
Capabilities: [d0] Vital Product Data
Capabilities: [100] Advanced Error Reporting
Capabilities: [148] Virtual Channel
Capabilities: [168] Device Serial Number 00-00-00-00-00-00-00-00
Capabilities: [178] Transaction Processing Hints
Capabilities: [204] Latency Tolerance Reporting
Capabilities: [20c] L1 PM Substates
Capabilities: [21c] Vendor Specific Information: ID=0002 Rev=4 Len=100 <?>
Kernel driver in use: r8169
Kernel modules: r8169
0000:04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
Subsystem: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller
Flags: fast devsel, IRQ 18, IOMMU group 18
I/O ports at 5000
Memory at 86010000 (64-bit, non-prefetchable) [size=64K]
Memory at 86020000 (64-bit, non-prefetchable) [size=16K]
Expansion ROM at 86000000 [disabled] [size=64K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Capabilities: [70] Express Endpoint, MSI 01
Capabilities: [b0] MSI-X: Enable+ Count=32 Masked-
Capabilities: [d0] Vital Product Data
Capabilities: [100] Advanced Error Reporting
Capabilities: [148] Virtual Channel
Capabilities: [168] Device Serial Number 00-00-00-00-00-00-00-00
Capabilities: [178] Transaction Processing Hints
Capabilities: [204] Latency Tolerance Reporting
Capabilities: [20c] L1 PM Substates
Capabilities: [21c] Vendor Specific Information: ID=0002 Rev=4 Len=100 <?>
Kernel driver in use: r8169
Kernel modules: r8169
0000:05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
Subsystem: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller
Flags: fast devsel, IRQ 18, IOMMU group 19
I/O ports at 4000
Memory at 85f10000 (64-bit, non-prefetchable) [size=64K]
Memory at 85f20000 (64-bit, non-prefetchable) [size=16K]
Expansion ROM at 85f00000 [disabled] [size=64K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Capabilities: [70] Express Endpoint, MSI 01
Capabilities: [b0] MSI-X: Enable+ Count=32 Masked-
Capabilities: [d0] Vital Product Data
Capabilities: [100] Advanced Error Reporting
Capabilities: [148] Virtual Channel
Capabilities: [168] Device Serial Number 00-00-00-00-00-00-00-00
Capabilities: [178] Transaction Processing Hints
Capabilities: [204] Latency Tolerance Reporting
Capabilities: [20c] L1 PM Substates
Capabilities: [21c] Vendor Specific Information: ID=0002 Rev=4 Len=100 <?>
Kernel driver in use: r8169
Kernel modules: r8169
0000:06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
Subsystem: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller
Flags: fast devsel, IRQ 18, IOMMU group 20
I/O ports at 3000
Memory at 85e10000 (64-bit, non-prefetchable) [size=64K]
Memory at 85e20000 (64-bit, non-prefetchable) [size=16K]
Expansion ROM at 85e00000 [disabled] [size=64K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Capabilities: [70] Express Endpoint, MSI 01
Capabilities: [b0] MSI-X: Enable+ Count=32 Masked-
Capabilities: [d0] Vital Product Data
Capabilities: [100] Advanced Error Reporting
Capabilities: [148] Virtual Channel
Capabilities: [168] Device Serial Number 00-00-00-00-00-00-00-00
Capabilities: [178] Transaction Processing Hints
Capabilities: [204] Latency Tolerance Reporting
Capabilities: [20c] L1 PM Substates
Capabilities: [21c] Vendor Specific Information: ID=0002 Rev=4 Len=100 <?>
Kernel driver in use: r8169
Kernel modules: r8169
0000:0a:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 05)
DeviceName: RTL8125 2.5GbE Controller
Subsystem: ASUSTeK Computer Inc. RTL8125 2.5GbE Controller
Flags: bus master, fast devsel, latency 0, IRQ 18, IOMMU group 21
I/O ports at 8000
Memory at 86200000 (64-bit, non-prefetchable) [size=64K]
Memory at 86210000 (64-bit, non-prefetchable) [size=16K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Capabilities: [70] Express Endpoint, MSI 01
Capabilities: [b0] MSI-X: Enable+ Count=32 Masked-
Capabilities: [d0] Vital Product Data
Capabilities: [100] Advanced Error Reporting
Capabilities: [148] Virtual Channel
Capabilities: [168] Device Serial Number 01-00-00-00-68-4c-e0-00
Capabilities: [178] Transaction Processing Hints
Capabilities: [204] Latency Tolerance Reporting
Capabilities: [20c] L1 PM Substates
Capabilities: [21c] Vendor Specific Information: ID=0002 Rev=4 Len=100 <?>
Kernel driver in use: r8169
Kernel modules: r8169
从这个输出中,可以看到 0000:0a:00.0 对应的是 rev 05 版本的网卡。接下来我们需要确认这个设备和管理接口的关联性。
四. 通过 ethtool 确认网卡对应的PCI总线ID
使用 ethtool 查看 eno1 的总线信息,以确认它是否对应 0000:0a:00.0:
➜ ~ ethtool -i eno1
driver: r8169
version: 6.8.4-2-pve
firmware-version: rtl8125b-2_0.0.2 07/13/20
expansion-rom-version:
bus-info: 0000:0a:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no
从 ethtool 的输出可以确认,eno1 的总线ID是 0000:0a:00.0,这与 lspci -v 中 rev 05 的设备一致。因此,eno1 确实是连接管理网络的物理网卡。
四. 总结
|