1. 描述

当我们想在操作系统里面查看网口和交换机连接的状态信息,我们可以使用lldptool这个工具。

2.LLDP协议

LLDP是一个数据链路层发现协议,LLDP协议使得接入网络的一台设备可以将其主要的能力,管理地址,设备标识,接口标识等信息发送给接入同一个局域网络的其它设备。lldptool工具采用的是LLDP协议,一般我们使用lldptool是为了得到设备的物理拓扑结构以及管理配置信息,比如说,和eth1网口相连的网络交换机的Vlan ID是多少?网络交换机的名称是什么?网线插在网络交换机的什么地方?

在这里我们不去讨论LLDP协议的架构和具体时序状态码等,这里仅仅介绍怎么用它。

LLDP协议有四种工作模式:

TxRx:既发送也接收LLDP 帧

Tx    :只发送不接收LLDP 帧

Rx:只接收不发送LLDP 帧

Disable:既不发送也不接收

一般设置LLDP工作在TxRx模式。

3.lldptool的命令格式

lldptool [options] [参数]

Options

-i [ifname]

specifies the network interface to which the command applies

-V [tlvid]

specifies the TLV identifier

The tlvid is an integer value used to identify specific LLDP TLVs. The tlvid value is the Type value for types not equal to 127 (the organizationally specific type). For organizationally specific TLVs, the tlvid is the value represented by the 3 byte OUI and 1 byte subtype - where the subtype is the lowest order byte of the tlvid.

The tlvid can be entered as a numerical value (e.g. 10 or 0xa), or for supported TLVs, as a keyword. Review the

lldptool help output to see the list of supported TLV keywords.

-n

"neighbor" option for commands which can use it (e.g. get-tlv)

-g [bridge scope]

specify the bridge scope this command operates on. Allows to set and query all LLDP TLV modules for "nearest_bridge" (short: "nb"), "nearest_customer_bridge" ("ncb") and "nearest_nontpmr_bridge" ("nntpmrb") group mac addresses. Configurations are saved into independent sections in lldpad.conf. If no bridge scope is supplied this default to "nearest bridge" to preserve the previous behaviour.

-c

"config" option for TLV queries. Indicates that the query is for the configuration elements for the specified TLV. The argument list specifies the specific elements to query. If no arguments are listed, then all configuration elements for the TLV are returned.

-r

show raw client interface messages

-R

show only raw Client interface messages

Commands

license

show license information

-h, help

show usage information

-v, version

show version information

-S, stats

get LLDP statistics

-t, get-tlv

get TLV information

-T, set-tlv

set TLV information

-l, get-lldp

get LLDP parameters

-L, set-lldp

set LLDP parameters

-q, quit

exit from interactive mode

4.lldptool使用举例

ip a查看启用网口:

先看一些有没有lldptool工具,如果没有的话yum装一下:

[root@wow ~]# service lldpad status

lldpad is stopped

[root@wow~]# service lldpad start

Starting lldpad: [ OK ]

[root@wow~]#

先设置lldptool的工作模式:

[root@wow ~]# lldptool set-lldp -i eth0 adminStatus=rxtx

adminStatus= rxtx  #这样就和网络交换机建立了邻居关系,接下来就可以查询连接的交换机信息了

使用lldptool查看网口与交换机连接状态:

[root@wow ~]# lldptool -t -n -i eth0

Chassis ID TLV

MAC:48:xx:xx:xx:xx:51  #mac地址Port ID TLV

Ifname: GE1/0/1#网线插在交换机上的端口位置Time to Live TLV120System Name TLV

xx-xx-CE5850-xxxxx#交换机设备名System Description TLV

Huawei Versatile Routing Platform Software

VRP (R) software, Version8.150(CE5855EI V200R002C50SPC800)

Copyright (C)2012-2017Huawei Technologies Co., Ltd.

HUAWEI CE5855-xxxx-xxx  #华为的交换机

System Capabilities TLV

System capabilities: Bridge, Router

Enabled capabilities: Bridge, Router

Management Address TLV

IPv4: xx.xxx.xxx.xx  #ip地址

Ifindex:4OID:+[)

Port VLAN ID TLV

PVID:Port and Protocol VLAN ID TLV

PVID:0, not supported, not enabled

VLAN Name TLV

VID3652: Name VLAN3652

MAC/PHY Configuration Status TLV

Auto-negotiation supported and enabled

PMD auto-negotiation capabilities: 0xxxxxMAU type:1000BaseXFD

Link Aggregation TLV

Aggregation capable

Currently not aggregated

Aggregated Port ID:0Maximum Frame Size TLV9216End of LLDPDU TLV

[root@wow~]#

如果想利用lldptool对网口进行一些设置,可以参考手册,下面是在Linux上找男人看到的一些例子:

Configure LLDP adminStatus to Receive and Transmit forinterface eth2  #为网口eth2配置LLDP的收发工作模式

lldptool-L -i eth2 adminStatus=rxtx

lldptool set-lldp -i eth2 adminStatus=rxtx

Disable the LLDP adminStatusforall interfaces  #让所有网口都不可用LLDP

lldptool set-lldp adminStatus=disabled

Query the LLDP adminStatusforinterface eth3  #查询网口eth3的LLDP状态

lldptool-l -i eth3 adminStatus

lldptool get-lldp -i eth3 adminStatus

Query the LLDP statisticsforinterface eth3   #查询网口eth3的统计信息

lldptool-S -i eth3 adminStatus

lldptool stats-i eth3 adminStatus

Query the local TLVswhich are being transmitted fora given interface:   #查询为给定接口传输的本地

lldptool-t -i eth3

lldptool get-tlv -i eth3

Query the received neighbor TLVs received on a given interface:  #查询给定接口上收到的接收邻居TLV

lldptool-t -n -i eth3

lldptool get-tlv -n -i eth3

Query the value of the System Description TLV as received from the neighbor on a given interface:

lldptool-t -n -i eth3 -V sysDesc

lldptool get-tlv -n -i eth3 -V 6Disable transmit of the IEEE802.3 MAC/PHY Configuration Status TLV fora given interface:

lldptool-T -i eth3 -V macPhyCfg enableTx=no

lldptool set-tlv -i eth3 -V 0x120f01 enableTx=no

Enable transmit of the Port Description TLVforall interfaces:

lldptool-T -V portDesc enableTx=yes

lldptool set-tlv -V 4 enableTx=yes

Query value of the transmit settingfor the Port Description TLV fora given interface:

lldptool-t -V portDesc -c enableTx

lldptool get-tlv -V 4 -c enableTx

Set a Management Address TLV on eth3 to carry IPv4 address192.168.10.10lldptool-T -i eth3 -V mngAddr ipv4=192.168.10.10Set a Management Address TLV on eth3 to carry IPv6 address ::192.168.10.10lldptool-T -i eth3 -V mngAddr ipv6=::192.168.10.10Get the configured IPv4 addressforthe Management Address TLV on eth3

lldptool-t -i eth3 -V mngAddr-c ipv4

Get all configured attributesforthe Management Address TLV on eth3

lldptool-t -i eth3 -V mngAddr -c

Query the current DCBX mode that will be usediflldpad is restarted. (this is not a persistent setting)

lldptool-t-i eth3 -V IEEE-DCBX -c mode

Reset the DCBX mode to be'auto' (start inIEEE DCBX mode) after the next lldpad restart

lldptool-T -i eth3 -V IEEE-DCBX mode=reset

Enable transmit of the Edge Virtual Bridging TLVforinterface eth4

lldptool-i eth4-T -V evbCfg enableTx=yes

Configure EVB TLV to set reflective relay and RTE,ECP and VDP capabilities

lldptool-T -i eth4 -V evbCfg fmode=reflectiverelay

lldptool-T -i eth4 -V evbCfg capabilities=rte,ecp,vdp

Enable transmit of the VDPforinterface eth4

lldptool-i eth4 -T -V vdp enableTx=yes

Configurations per port have higher precedence than global configurations.

mysql lisensce_Linux之lldptool命令相关推荐

  1. Centos7 MYSQL安装与基础命令运用

    Centos7 MYSQL安装与基础命令运用 1.关闭防火墙,selinux systemctl stop firewalld setenforce 0 2.实现虚拟机能够上网,所以说要两块网卡,一块 ...

  2. mysql带c的命令_mysql命令整理

    一.总结一下: 1.linux下启动mysql的命令: mysqladmin start /etc/init.d/mysql start (前面为mysql的安装路径) 2.linux下重启mysql ...

  3. 滴水穿石--MYSQL导入导出常用命令

    一.MYSQL的命令行模式的设置: 桌面->我的电脑->属性->环境变量->新建-> PATH=";path\mysql\bin;"其中path为MY ...

  4. 查看MySQL数据库表的命令介绍

    如果需要查看MySQL数据库中都有哪些MySQL数据库表,应该如何实现呢?下面就为您介绍查看MySQL数据库表的命令,供您参考. 进入MySQL Command line client下 查看当前使用 ...

  5. mysql一些写常用命令

    参见pcttcnc2007博客腾飞 1.mysql的status信息命令: mysql> show global status; 2.可以列出mysql服务器运行各种状态值,另外,查询mysql ...

  6. mysql check table_修复MySQL的MyISAM表命令check table用法

    MyISAM如果损坏了修复方法是比较简单了我们只要使用check table命令就可以了,下面我们来看一篇关于修复MySQL的MyISAM表命令check table用法,具体如下所示. MySQL日 ...

  7. mysql导入sql脚本命令

    2019独角兽企业重金招聘Python工程师标准>>> 使用mysql自带的命令行工具导入sql脚本如下: mysql -h localhost -u root -proot -v ...

  8. linux中mysql导入文件,linux下mysql导入sql文件命令

    Linux下我们提供导入sql文件可以得到数据.下面由学习啦小编为大家整理了linux下mysql导入sql文件命令的相关知识,希望对大家有帮助! linux的mysql导入sql文件命令详解 lin ...

  9. mysql查看表结构命令

    原文:http://www.blogjava.net/etlan/archive/2007/07/12/129794.html mysql查看表结构命令 mysql查看表结构命令,如下: desc 表 ...

最新文章

  1. hadoop+spark生态系统操作与指南非影印版_Spark背景知识学习
  2. python 代码生成器 oc_iOS 移动端生成工具开发
  3. 大讲堂 | 预测时间敏感的机器学习模型建模与优化
  4. AtCoder Beginner Contest 194 E - Mex Min 思维
  5. qchart能绘制三维_诺斯顿三维测量:走进无人机倾斜摄影的世界
  6. 【Elasticsearch】es 7.8.0 唐诗三百首写入 Elasticsearch 会发生什么
  7. Windows Driver开发_安装与配置环境
  8. Ubuntu LVM扩展LV
  9. 在dos窗口中删除services中的服务
  10. 价值1400美元的CEH(道德黑客)认证培训课程长啥样?(3)工具集
  11. 谷歌地球下载及功能介绍
  12. iOS ApplePay paymentData 加解密 (待续)
  13. oracle 加载dbf文件路径,Oracle 导入DBF故障存储文件
  14. 遇见未来 | 对话朱贤文:PostgreSQL是一匹即将发力的黑马
  15. perl 一行命令 2021-09-02
  16. Python实现从excel读取数据并绘制成精美图像
  17. excel表格中单元格里面有个斜杠怎么写字?
  18. 【Unity编程】四元数(Quaternion)与欧拉角
  19. Vue 前端导出Excel表格,多级表头合并
  20. 电子天平的检定和检定结果的影响因素

热门文章

  1. java汽车生产工厂模式_什么是工厂模式java
  2. 成功解决Exception “unhandled ModuleNotFoundError“No module named ‘face_recognition.cli‘
  3. 成功解决 shape = predictor(img, dets[0]) IndexError: Index out of range
  4. RL之SARSA:利用强化学习之SARSA实现走迷宫—训练智能体走到迷宫(复杂陷阱迷宫)的宝藏位置
  5. Python之tkinter:动态演示调用python库的tkinter带你进入GUI世界(Listbox/Scrollbar)
  6. 8.2 TensorFlow实现KNN与TensorFlow中的损失函数,优化函数
  7. Visual Code 快捷创建HTML,CSS和Class
  8. 透过源码看Session
  9. template_1
  10. ASP.NET内置对象的总结