通过lldp协议识别物理服务器网卡接入的交换机端口信息随记
来自三线的随记
首先启动一个守护进程:
docker run --rm --net=host --uts=host -v /etc/os-release:/etc/os-release:ro --cap-add=NET_ADMIN --name lldpd-daemon ghcr.io/lldpd/lldpd:latest
再开一个shell ,利用之前启动的daemon查看协议
docker exec lldpd-daemon show neighbors
回显效果如下:
对于物理网卡能看到交换机端口接入信息(需要交换机兼容开启 lldp 协议)
有的物理服务器的带外管理页面里面,网卡状态也会呈现交换机端口接入信息,结合这些信息可以做好网络端口接入核对
# docker exec lldpd-daemon lldpcli show neighbors ------------------------------------------------------------------------------- LLDP neighbors: ------------------------------------------------------------------------------- Interface: eth0, via: LLDP, RID: 1, Time: 0 day, 00:00:58 Chassis: ChassisID: mac b4:09:31:dd:aa:ee SysName: A56-A57-S5735 SysDescr: Huawei Switch S5735-L48T4X-A Huawei Versatile Routing Platform Software VRP (R) software, Version 5.170 (S5735 V200R019C10SPC500) Copyright (C) 2000-2020 HUAWEI TECH Co., Ltd. MgmtIP: 192.168.1.253 MgmtIface: 4 Capability: Bridge, on Capability: Router, on Port: PortID: ifname GigabitEthernet0/0/4 PortDescr: to-4-5U TTL: 120 Unknown TLVs: TLV: OUI: 00,18,82, SubType: 40, Len: 4 00,00,00,01 ------------------------------------------------------------------------------- Interface: eth1, via: LLDP, RID: 1, Time: 0 day, 00:00:58 Chassis: ChassisID: mac b4:09:32:dd:aa:ed SysName: A56-A57-S5735 SysDescr: Huawei Switch S5735-L48T4X-A Huawei Versatile Routing Platform Software VRP (R) software, Version 5.170 (S5735 V200R019C10SPC500) Copyright (C) 2000-2020 HUAWEI TECH Co., Ltd. MgmtIP: 192.168.1.253 MgmtIface: 4 Capability: Bridge, on Capability: Router, on Port: PortID: ifname GigabitEthernet0/0/5 PortDescr: to-4U-5U-eth2 TTL: 120 Unknown TLVs: TLV: OUI: 00,18,82, SubType: 40, Len: 4 00,00,00,01 -------------------------------------------------------------------------------