使用的命令是:lldpad
使用方法:
[root@112o26 ~]# yum install lldpad -y
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
base | 3.6 kB 00:00:00
saltstack-repo | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package lldpad.x86_64 0:1.0.1-3.git036e314.el7 will be installed
--> Processing Dependency: libconfig.so.9()(64bit) for package: lldpad-1.0.1-3.git036e314.el7.x86_64
--> Running transaction check
---> Package libconfig.x86_64 0:1.4.9-5.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================================================================================
Installing:
lldpad x86_64 1.0.1-3.git036e314.el7 base 283 k
Installing for dependencies:
libconfig x86_64 1.4.9-5.el7 base 59 k
Transaction Summary
===================================================================================================================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 342 k
Installed size: 888 k
Downloading packages:
(1/2): libconfig-1.4.9-5.el7.x86_64.rpm | 59 kB 00:00:00
(2/2): lldpad-1.0.1-3.git036e314.el7.x86_64.rpm | 283 kB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.4 MB/s | 342 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libconfig-1.4.9-5.el7.x86_64 1/2
Installing : lldpad-1.0.1-3.git036e314.el7.x86_64 2/2
Verifying : libconfig-1.4.9-5.el7.x86_64 1/2
Verifying : lldpad-1.0.1-3.git036e314.el7.x86_64 2/2
Installed:
lldpad.x86_64 0:1.0.1-3.git036e314.el7
Dependency Installed:
libconfig.x86_64 0:1.4.9-5.el7
Complete!
[root@112o26 ~]# vim network.sh
[root@112o26 ~]# chmod 644 network.sh
[root@112o26 ~]# bash -x network.sh
[root@112o26 ~]# cat network.sh
for i in `ls /sys/class/net/ | grep "enp"`;
do echo "enabling lldp for interface: $i";
lldptool set-lldp -i $i adminStatus=rxtx;
lldptool -T -i $i -V sysName enableTx=yes;
lldptool -T -i $i -V portDesc enableTx=yes ;
lldptool -T -i $i -V sysDesc enableTx=yes;
lldptool -T -i $i -V sysCap enableTx=yes;
lldptool -T -i em1 -V mngAddr ipv4=`hostname -I`;
lldptool -T -i $i -V mngAddr enableTx=yes;
done
[root@112o26 ~]# lldptool -t -n -i xgbe0
Chassis ID TLV
MAC: 60:0b:03:a5:b7:ee
Port ID TLV
Ifname: Ten-GigabitEthernet1/0/12
Time to Live TLV
121
Port Description TLV
Ten-GigabitEthernet1/0/12 Interface
System Name TLV
HB-SSLTJCT-C1-S6800-1.Ssl
System Description TLV
H3C Comware Platform Software, Software Version 7.1.045, Release 2422P02
H3C S6800-54QF
Copyright (c) 2004-2016 Hangzhou H3C Tech. Co., Ltd. All rights reserved.
System Capabilities TLV
System capabilities: Bridge, Router
Enabled capabilities: Bridge, Router
Management Address TLV
IPv4: 172.17.0.1
Ifindex: 26771
Port VLAN ID TLV
PVID: 20
Link Aggregation TLV
Aggregation capable
Currently not aggregated
Aggregated Port ID: 0
MAC/PHY Configuration Status TLV
Auto-negotiation supported and enabled
PMD auto-negotiation capabilities: 0x0000
MAU type: 10G BaseSR
Power via MDI TLV
Port class PSE
PSE MDI power not supported
PSE pairs not controllable
PSE Power pair: signal
Power class 2
Maximum Frame Size TLV
10000
End of LLDPDU TLV