服务器如何通过命令查询网卡接的端口

使用的命令是: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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值