1. 什么是lldpd?
LLDP 可以让你准确的知道服务器所连接的交换机端口号。
LLDP是一种工业标准协议,用于取代EDP或CDP等专用链路层协议。LLDP的目标是提供一个inter-vendor兼容机制,向相邻网络设备发送链路层通知。
lldpd是一个LLDP协议的一种实现,给各种Unixes使用。除此之外,它还支持一些专有协议。
1.1. lldpad与lldpd的对比
实现交换机端口的抓取,目前我知道的有两种工具,一种是lldpad,另一种是lldpd。
这两个工具做了一下对比,最终选择了lldpd。原因如下:
- lldpd比较新。
lldpad:https://github.com/jrfastab/lldpad
lldpd:https://github.com/vincentbernat/lldpd
通过对比可以看到lldpad最近一次更新,已经是5年前了。而lldpd的最近一次更新在本月。
- lldpd使用方便。
lldpd可以将输出的信息转化为json格式,非常方便使用。
1.2. 安装lldpd
需要先配置好配置好epel-release源,然后直接yum安装即可。
yum install lldpd systemctl start lldpd
安装好之后,你可以修改/etc/sysconfig/lldpd文件,来配置一些参数。
1.3. 使用lldpcli
lldpd有两个模块。一个是lldpd的后台程序,用于接收和发送LLDP报文;一个是lldpcli用来查询和配置后台程序的工具。
- 查看所有端口的交换机信息。
[root@test01 ~]# lldpcli show neighbors
------------------------------------------------------------------------------- LLDP neighbors: ------------------------------------------------------------------------------- Interface: eth0, via: LLDP, RID: 1, Time: 0 day, 00:00:02 Chassis: ChassisID: mac 90:e7:10:5a:c5:3a SysName: SW-TEST001 SysDescr: H3C Comware Platform Software, Software Version 7.1.070, ESS 6552 H3C S6850-56HF Copyright (c) 2004-2018 New H3C Technologies Co., Ltd. All rights reserved. MgmtIP: 192.168.3.129 Capability: Bridge, on Capability: Router, on Port: PortID: ifname Twenty-FiveGigE1/0/53 PortDescr: Twenty-FiveGigE1/0/53 Interface TTL: 121 -------------------------------------------------------------------------------
- 查看某个端口的交换机信息。
[root@test01 ~]# lldpcli show neighbors ports eth0 summary
------------------------------------------------------------------------------- LLDP neighbors: ------------------------------------------------------------------------------- Interface: eth0, via: LLDP Chassis: ChassisID: mac 90:e7:10:5a:c5:3a SysName: SW-TEST001 Port: PortID: ifname Twenty-FiveGigE1/0/53 PortDescr: Twenty-FiveGigE1/0/53 Interface TTL: 121 -------------------------------------------------------------------------------
- 查看所有端口的本地信息。(即使未接线,也会显示)
[root@test01 ~]# lldpcli show interfaces ------------------------------------------------------------------------------- LLDP interfaces: ------------------------------------------------------------------------------- Interface: eth0, via: LLDP, Time: 0 day, 00:59:51 Chassis: ChassisID: mac e4:43:4b:42:fe:ec SysName: test01.localadmin SysDescr: CentOS Linux 7 (Core) Linux 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 MgmtIP: 192.168.1.10 MgmtIP: fe80::e643:4bff:fe42:feec Capability: Bridge, off Capability: Router, off Capability: Wlan, off Capability: Station, on Port: PortID: mac e4:43:4b:42:fe:ec PortDescr: eth0 TTL: 120 ------------------------------------------------------------------------------- Interface: eth1, via: LLDP, Time: 0 day, 00:59:51 Chassis: ChassisID: mac e4:43:4b:42:fe:ec SysName: test01.localadmin SysDescr: CentOS Linux 7 (Core) Linux 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 MgmtIP: 192.168.1.10 MgmtIP: fe80::e643:4bff:fe42:feec Capability: Bridge, off Capability: Router, off Capability: Wlan, off Capability: Station, on Port: PortID: mac e4:43:4b:42:fe:ee PortDescr: eth1 TTL: 120 ------------------------------------------------------------------------------- Interface: eth2, via: unknown, Time: 17969 days, 04:42:04 Chassis: ChassisID: mac e4:43:4b:42:fe:ec SysName: test01.localadmin SysDescr: CentOS Linux 7 (Core) Linux 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 MgmtIP: 192.168.1.10 MgmtIP: fe80::e643:4bff:fe42:feec Capability: Bridge, off Capability: Router, off Capability: Wlan, off Capability: Station, on Port: PortID: mac e4:43:4b:42:ff:0c PortDescr: eth2 TTL: 120 ------------------------------------------------------------------------------- Interface: eth3, via: unknown, Time: 17969 days, 04:42:04 Chassis: ChassisID: mac e4:43:4b:42:fe:ec SysName: test01.localadmin SysDescr: CentOS Linux 7 (Core) Linux 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 MgmtIP: 192.168.1.10 MgmtIP: fe80::e643:4bff:fe42:feec Capability: Bridge, off Capability: Router, off Capability: Wlan, off Capability: Station, on Port: PortID: mac e4:43:4b:42:ff:0d PortDescr: eth3 TTL: 120 -------------------------------------------------------------------------------
- 查看某个端口的本地信息。(即使未接线,也会显示)
[root@test01 ~]# lldpcli show interfaces ports eth0 summary
------------------------------------------------------------------------------- LLDP interfaces: ------------------------------------------------------------------------------- Interface: eth0, via: LLDP Chassis: ChassisID: mac e4:43:4b:42:fe:ec SysName: test01.localadmin Port: PortID: mac e4:43:4b:42:fe:ec PortDescr: eth0 TTL: 120 -------------------------------------------------------------------------------
- 查看本机的信息
[root@test01 ~]# lldpcli show chassis
------------------------------------------------------------------------------- Local chassis: ------------------------------------------------------------------------------- Chassis: ChassisID: mac e4:43:4b:42:fe:ec SysName: test01.localadmin SysDescr: CentOS Linux 7 (Core) Linux 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 MgmtIP: 192.168.1.10 MgmtIP: fe80::e643:4bff:fe42:feec Capability: Bridge, off Capability: Router, off Capability: Wlan, off Capability: Station, on -------------------------------------------------------------------------------
1.4. 格式化数据结果
将上述命令,加上 -f json 可以转变输出结果。这个功能非常有用,有利于自动化处理这些数据。
[root@test01 ~]# lldpcli show neighbors ports eth0 summary -f json
{ "lldp": { "interface": { "eth0": { "via": "LLDP", "chassis": { "SW-TEST001": { "id": { "type": "mac", "value": "90:e7:10:5a:c5:3a" } } }, "port": { "id": { "type": "ifname", "value": "Twenty-FiveGigE1/0/53" }, "descr": "Twenty-FiveGigE1/0/53 Interface", "ttl": "121" } } } } }
2. 症状及处理方法
2.1. x710关闭lldp
- 现象症状:
使用x722 LOM,当lldpad启动时,lldptool -L adminStatus = rxtx -i < interface name>然后lldptool -tni < interface name>运行时,NIC端口连接到启用了LLDP的交换机,不会返回LLDP信息。 (其中LLDP =链路层发现协议)
- 解决办法:
运行commnand " echo lldp stop > / sys / kernel / debug / i40e / < PCIe路径> / command" ;.由于LOM沒有FCoE功能,沒有DCBx要求,所以沒有真正的功能影响。 (FCoE =以太网光纤通道)
- 附加信息:
根据Intel设计,x722适配器默认处理所有LLDP流量,LLDP流量将不会转到主机CPU,除非使用在x722中停止LLDP功能的命令。