Linux之lldptool命令
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 <command> [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 <argument list>
- "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: :xx:xx:xx:xx:51 #mac地址
Port ID TLV
Ifname: GE1//1 #网线插在交换机上的端口位置
Time to Live TLV System Name TLV
xx-xx-CE5850-xxxxx #交换机设备名
System Description TLV
Huawei Versatile Routing Platform Software
VRP (R) software, Version 8.150 (CE5855EI V200R002C50SPC800)
Copyright (C) - Huawei 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:
OID: +[)
Port VLAN ID TLV
PVID:
Port and Protocol VLAN ID TLV
PVID: , not supported, not enabled
VLAN Name TLV
VID : Name VLAN3652
MAC/PHY Configuration Status TLV
Auto-negotiation supported and enabled
PMD auto-negotiation capabilities: 0xxxxx
MAU type: BaseXFD
Link Aggregation TLV
Aggregation capable
Currently not aggregated
Aggregated Port ID:
Maximum Frame Size TLV End of LLDPDU TLV
[root@wow ~]#
如果想利用lldptool对网口进行一些设置,可以参考手册,下面是在Linux上找男人看到的一些例子:
Configure LLDP adminStatus to Receive and Transmit for interface eth2 #为网口eth2配置LLDP的收发工作模式
lldptool -L -i eth2 adminStatus=rxtx
lldptool set-lldp -i eth2 adminStatus=rxtx Disable the LLDP adminStatus for all interfaces #让所有网口都不可用LLDP
lldptool set-lldp adminStatus=disabled
Query the LLDP adminStatus for interface eth3 #查询网口eth3的LLDP状态
lldptool -l -i eth3 adminStatus
lldptool get-lldp -i eth3 adminStatus Query the LLDP statistics for interface eth3 #查询网口eth3的统计信息
lldptool -S -i eth3 adminStatus
lldptool stats -i eth3 adminStatus Query the local TLVs which are being transmitted for a 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 Disable transmit of the IEEE 802.3 MAC/PHY Configuration Status TLV for a 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 TLV for all interfaces:
lldptool -T -V portDesc enableTx=yes
lldptool set-tlv -V enableTx=yes Query value of the transmit setting for the Port Description TLV for a given interface:
lldptool -t -V portDesc -c enableTx
lldptool get-tlv -V -c enableTx Set a Management Address TLV on eth3 to carry IPv4 address 192.168.10.10
lldptool -T -i eth3 -V mngAddr ipv4=192.168.10.10
Set a Management Address TLV on eth3 to carry IPv6 address ::192.168.10.10
lldptool -T -i eth3 -V mngAddr ipv6=::192.168.10.10 Get the configured IPv4 address for the Management Address TLV on eth3
lldptool -t -i eth3 -V mngAddr
- c ipv4 Get all configured attributes for the Management Address TLV on eth3
lldptool -t -i eth3 -V mngAddr -c
Query the current DCBX mode that will be used if lldpad 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 in IEEE DCBX mode) after the next lldpad restart
lldptool -T -i eth3 -V IEEE-DCBX mode=reset
Enable transmit of the Edge Virtual Bridging TLV for interface 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 VDP for interface eth4
lldptool -i eth4 -T -V vdp enableTx=yes
Configurations per port have higher precedence than global configurations.
Linux之lldptool命令的更多相关文章
- Linux下history命令用法
如果你经常使用 Linux 命令行,那么使用 history(历史)命令可以有效地提升你的效率.本文将通过实例的方式向你介绍 history 命令的 15 个用法. 使用 HISTTIMEFORMAT ...
- Linux下ps命令详解 Linux下ps命令的详细使用方法
http://www.jb51.net/LINUXjishu/56578.html Linux下的ps命令比较常用 Linux下ps命令详解Linux上进程有5种状态:1. 运行(正在运行或在运行队列 ...
- 例解 Linux 下 Make 命令
Linux 下 make 命令是系统管理员和程序员用的最频繁的命令之一.管理员用它通过命令行来编译和安装很多开源的工具,程序员用它来管理他们大型复杂的项目编译问题.本文我们将用一些实例来讨论 make ...
- Linux终端打印命令使用介绍
常用linux打印命令 日常使用中或shell脚本中linux终端打印命令有echo和printf. echo命令 功能说明:显示文字.语 法:echo [-ne][字符串]或 echo [--he ...
- linux常用的命令
Linux简介及Ubuntu安装 Linux,免费开源,多用户多任务系统.基于Linux有多个版本的衍生.RedHat.Ubuntu.Debian 安装VMware或VirtualBox虚拟机.具体安 ...
- 查看linux系统版本命令 (转)
查看linux系统版本命令 分类: Linux 知识小结2011-10-10 15:26 240162人阅读 评论(9) 收藏 举报 linuxredhatdebianx86susesun 一.查看内 ...
- linux入门级常用命令
1) 关闭Linux系统的命令:init 02) Linux终端:Linux终端也称为虚拟控制台.Linux终端采用字符命令行方式工作,用户通过键盘输入命令,通过Linux终端对系统进行控制.3) 切 ...
- linux之find命令详解
linux之find命令详解 查找文件find ./ -type f查找目录find ./ -type d查找名字为test的文件或目录find ./ -name test查找名字符合正则表达式的文件 ...
- 12个Linux进程管理命令介绍(转)
12个Linux进程管理命令介绍 [日期:2015-06-02] 来源:Linux中国 作者:Linux [字体:大 中 小] 执行中的程序在称作进程.当程序以可执行文件存放在存储中,并且运行的 ...
随机推荐
- GoldenGate 异常处理预案
异常处理一般步骤 如果GoldenGate复制出现异常,可以通过以下步骤尝试解决问题: 1) 通过ggsci>view report命令查找ERROR字样,确定错误原因并根据其信息 ...
- Debian9.5下sftp配置和scp用法
基于 ssh 的 sftp 服务相比 ftp 有更好的安全性(非明文帐号密码传输)和方便的权限管理(限制用户的活动目录). 1.如果只想让某些用户只能使用 sftp 操作文件, 而不能通过ssh进行服 ...
- [HAOI2016]找相同字符 广义后缀自动机_统计出现次数
题目描述:给定两个字符串,求出在两个字符串中各取出一个子串使得这两个子串相同的方案数.两个方案不同当且仅当这两个子串中有一个位置不同. 输入输出格式输入格式:两行,两个字符串 s1,s2,长度分别为n ...
- [国家集训队]拉拉队排练 Manancher_前缀和_快速幂
Code: #include <cstdio> #include <algorithm> #include <cstring> using namespace st ...
- 与 JSON 相关的一些操作 (项目中用到一部分,后续逐渐完善)
1.JSON 打印 console.log(JSON.stringify(data, null, 4)); 2.JSON 格式判断 var isjson = typeof(obj) == " ...
- 洛谷1726 上白泽慧音 tarjan模板
题目描述 在幻想乡,上白泽慧音是以知识渊博闻名的老师.春雪异变导致人间之里的很多道路都被大雪堵塞,使有的学生不能顺利地到达慧音所在的村庄.因此慧音决定换一个能够聚集最多人数的村庄作为新的教学地点.人间 ...
- [洛谷P3932]浮游大陆的68号岛
题目大意:有一行物品,每两个物品之间有一个距离.每个物品有一个价值.现在问你若干问题,每个问题问你把l~r所有物品全部搬到物品x处需要多少价值. 把物品a搬到物品b处的价值为物品a的价值乘a到b的距离 ...
- BZOJ4472
某售货员小T要到若干城镇去推销商品,由于该地区是交通不便的山区,任意两个城镇 之间都只有唯一的可能经过其它城镇的路线. 小T 可以准确地估计出在每个城镇停留的净收 益.这些净收益可能是负数,即推销商品 ...
- js闭包实例展示
准确来说,闭包是基于正常的垃圾回收处理机制下的.也就是说,一般情况一个函数(函数作用域)执行完毕,里面声明的变量会全部释放,被垃圾回收器回收.但闭包利用一个技巧,让作用域里面的变量,在函数执行完之后依 ...
- 紫书 习题 10-13 UVa 11526(打表找规律+分步枚举)
首先看这道题目,我预感商数肯定是有规律的排列的,于是我打表找一下规律 100 / 1 = 100 100 / 2 = 50 100 / 3 = 33 100 / 4 = 25 100 / 5 = ...