Cisco私有协议CDP

                    Cisco路由器CDP协议、

 

注:cdp用到的地方不多、再加上是Cisco设备的私有协议,所以大家可以用来做了解。但是一定要知道有这个东西,说不定就会有用到的一天了。因为既然Cisco开发这个协议了,不可能说是没用的。

 

CDP协议是Cisco专有协议,是使Cisco网络设备能够发现相邻的、直连的其他Cisco设备的协议。CDP是数据层的协议,因此使用不同的网络层协议的Cisco设备也可以获得对方的信息。CDP协议默认是启动的。下面我们做个小实验:


Cisco私有协议CDP

因为Cisco路由设备的接口默认是关闭的、所以我们把路由器的接口打开:

 

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#hostname

Router(config)#hostname R1

R1(config)#int f0/0

R1(config-if)#no sh     //这是一个缩写命令,打开接口、no shutdown~要想关闭接口就是shutdown~

 

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

 

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

 

R1(config-if)#exit       //退会到上一级、退出端口、也可以用来从配置模式退回特权模式、从特权模式退回到用户模式、从用户模式退出路由器、

R1(config)#int s0/3/0

R1(config-if)#no sh

 

%LINK-5-CHANGED: Interface Serial0/3/0, changed state to down

R1(config-if)#clock rate 64000    //配置广域网端口的时钟、我们就使用64000吧、接口时钟要一样才能进行通讯。

 

然后把R2的连接的接口也都开启。交换机接口默认是开启的所以就不用手动开启了。接下来就会看到路由器都发现自己的邻居了。

查看CDP配置:

R1>en

R1#show cdp                                 //查看CDP配置

Global CDP information:

    Sending CDP packets every 60 seconds

    Sending a holdtime value of 180 seconds

    Sending CDPv2 advertisements is enabled    //CDP默认是开启的,每60s从接口发送CDP消息、发送出的CDP消息邻居会为他保存180s,意思就是超过180s邻居还没有发来CDP消息的话,那就说明失去这个邻居了。

R1#show cdp interface                         //查看运行CDP的接口

Vlan1 is administratively down, line protocol is down

  Sending CDP packets every 60 seconds

  Holdtime is 180 seconds

FastEthernet0/0 is up, line protocol is up

  Sending CDP packets every 60 seconds

  Holdtime is 180 seconds

FastEthernet0/1 is administratively down, line protocol is down

  Sending CDP packets every 60 seconds

  Holdtime is 180 seconds

Serial0/3/0 is up, line protocol is up

  Sending CDP packets every 60 seconds

  Holdtime is 180 seconds

Serial0/3/1 is administratively down, line protocol is down

  Sending CDP packets every 60 seconds

  Holdtime is 180 seconds            

以上是显示本机发现运行CDP的接口。

 

查看CDP邻居:

R1#show cdp neighbors

Capability Codes: R – Router, T – Trans Bridge, B – Source Route Bridge

                  S – Switch, H – Host, I – IGMP, r – Repeater, P – Phone

Device ID    Local Intrfce   Holdtme    Capability   Platform    Port ID

Switch       Fas 0/0          151            S       2960        Fas 0/1

R2           Ser 0/3/0        173            R       C2800       Ser 0/3/0

R1#

以上信息说明路由器R1有两个CDP邻居:R2和S1。“Device ID”表示邻居主机名,“Local Intrfce”表示本机通过该接口与邻居相连、注意这里指的是本机。“Holdtme”表示收到邻居CDP消息的时间,采用倒计时的方式。“Capability”表示邻居是什么设备(S交换机,R路由器)。“Platform”表示邻居设备的硬件型号。“Port ID”表示本机连接邻居时连接的邻居的哪个端口。

R1#show cdp entry R2

 

Device ID: R2

Entry address(es):

Platform: cisco C2800, Capabilities: Router

Interface: Serial0/3/0, Port ID (outgoing port): Serial0/3/0

Holdtime: 166

 

Version :

Cisco IOS Software, 2800 Software (C2800NM-ADVIPSERVICESK9-M), Version 12.4(15)T1, RELEASE SOFTWARE (fc2)

Technical Support: http://www.cisco.com/techsupport

Copyright (c) 1986-2007 by Cisco Systems, Inc.

Compiled Wed 18-Jul-07 06:21 by pt_rel_team

 

advertisement version: 2

Duplex: full

—————————

 

R1#

以上是查看邻居R2的详细信息。甚至可以查看到邻居的ISO的版本。

 

R1#clear cdp table              //清除cdp邻居。

 

下面我们说开、关cdp协议,调整cdp协议参数:

R1#

R1#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#int f0/0

R1(config-if)#no cdp enable

R1(config-if)#   

以上是在接口f0/0上关闭cdp协议,不影响其他接口。

 

R1(config-if)#exit

R1(config)#no cdp run        //在整个设备上关闭cdp协议

R1(config)#cdp run          //在整个设备上开启cdp协议

(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)

未经允许不得转载:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权!路由网 » Cisco私有协议CDP