CISCO路由器和交换机都使用相同的参数。
Global CDP information:
Sending CDP packets every 60 seconds
Sending a holdtime value of 180 seconds
Global CDP information:
Sending CDP packets every 60 seconds
Sending a holdtime value of 180 seconds
可见默认情况下路由器发送V1版本的CDP信息,而交换机默认发送V2版本的CDP信息。
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#cdp ?
advertise-v2 CDP sends version-2 advertisements
holdtime Specify the holdtime (in sec) to be sent in packets
timer Specify the rate at which CDP packets are sent (in sec)
run
SW1(config)#cdp timer 90
SW1(config)#cdp holdtime 240
SW1(config)#
SW1#show
00:15:39: %SYS-5-CONFIG_I: Configured from console by console
SW1#show cdp
Global CDP information:
Sending CDP packets every 90 seconds
Sending a holdtime value of 240 seconds
Sending CDPv2 advertisements is enabled

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater
Device ID Local Intrfce Holdtme Capability Platform Port ID
SW1 Eth 0 154 T S WS-C2912-XFas 0/1
R2 Ser 0 161 R 2500 Ser 0
R1#
Holdtime :如果没有接收到其他CDP分组,路由器在丢弃接收到的信息之前将要保存的时间量。
Capability :邻居设备的类型,如路由器,交换机或中继器。
Platform :CISCO设备类型在上面的输出中cisco 2500和catalyst 2912是直连在路由器R1上的设备。
Port ID :与路由器R1直接相连的设备在发送更新时所用的接口。
另一个提供相邻设备信息的命令为show cdp neighbor命令,此命令可以在路由器或交换机上运行,它显示连接到此设备上的每个设备的详细信息,下面为命令输出的例子。
R1#show cdp neighbor detail
-------------------------
Device ID: SW1
Entry address(es):
IP address: 50.50.50.1
Platform: cisco WS-C2912-XL, Capabilities: Trans-Bridge Switch
Interface: Ethernet0, Port ID (outgoing port): FastEthernet0/1
Holdtime : 239 sec
Version :
Cisco Internetwork Operating System Software
IOS (tm) C2900XL Software (C2900XL-C3H2S-M), Version 12.0(5)WC14, RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2006 by cisco Systems, Inc.
Compiled Thu 16-Feb-06 14:39 by antonino
-------------------------
Device ID: R2
Entry address(es):
IP address: 10.10.10.2
Platform: cisco 2500, Capabilities: Router
Interface: Serial0, Port ID (outgoing port): Serial0
Holdtime : 126 sec
Version :
--More--
CDP-EV: Bad version number in header
CDP-PA: Packet received from SW1 on interface Ethernet0
**Entry found in cache**
Cisco Internetwork Operating System Software
IOS (tm) 3000 Software (IGS-I-L), Version 11.0(3), RELEASE SOFTWARE (fc1)
Copyright (c) 1986-1995 by cisco Systems, Inc.
Compiled Tue 07-Nov-95 15:04 by deannaw
R1#
Show cdp entry *命令与show cdp neighbor details命令所显示的为相同的信息。下面是show cdp entry *命令的路由器输出的例子。
-------------------------
Device ID: SW1
Entry address(es):
IP address: 50.50.50.1
Platform: cisco WS-C2912-XL, Capabilities: Trans-Bridge Switch
Interface: Ethernet0, Port ID (outgoing port): FastEthernet0/1
Holdtime : 204 sec
Version :
Cisco Internetwork Operating System Software
IOS (tm) C2900XL Software (C2900XL-C3H2S-M), Version 12.0(5)WC14, RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2006 by cisco Systems, Inc.
Compiled Thu 16-Feb-06 14:39 by antonino
-------------------------
Device ID: R2
Entry address(es):
IP address: 10.10.10.2
Platform: cisco 2500, Capabilities: Router
Interface: Serial0, Port ID (outgoing port): Serial0
Holdtime : 121 sec
Version :
Cisco Internetwork Operating System Software
IOS (tm) 3000 Software (IGS-I-L), Version 11.0(3), RELEASE SOFTWARE (fc1)
Copyright (c) 1986-1995 by cisco Systems, Inc.
Compiled Tue 07-Nov-95 15:04 by deannaw
R1#
CDP counters :
Packets output: 750, Input: 626
Hdr syntax: 212, Chksum error: 0, Encaps failed: 0
No memory: 0, Invalid packet: 0, Fragmented: 0
R1#
Ethernet0 is up, line protocol is up, encapsulation is ARPA
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial0 is up, line protocol is up, encapsulation is HDLC
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial1 is administratively down, line protocol is down, encapsulation is HDLC
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
R1#
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int e 0
R1(config-if)#no cdp enable
R1(config-if)#end
Serial0 is up, line protocol is up, encapsulation is HDLC
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial1 is administratively down, line protocol is down, encapsulation is HDLC
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
R1#
注意!上面路由器在输出中没有列出接口E0,说明此时已经成功关闭了E0接口的CDP功能。要想重新启动E0接口的CDP功能可在E0接口上运行命令cdp enable,此时E0口的CDP功能将得到重新恢复。
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int e 0
R1(config-if)#cdp enable
R1(config-if)#exi
R1(config)#exi
R1#show interfa
%SYS-5-CONFIG_I: Configured from console by console
R1#show cdp interface
Ethernet0 is up, line protocol is up, encapsulation is ARPA
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial0 is up, line protocol is up, encapsulation is HDLC
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial1 is administratively down, line protocol is down, encapsulation is HDLC
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
R1#
★ 保持时间是如何计时与清除超时信息的。 网管bitscn_com
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#int fa 0/1
SW1(config-if)#no cdp enable
SW1(config-if)#exi
SW1(config)#
然后我们到路由器R1上查看保持时间。
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater
Device ID Local Intrfce Holdtme Capability Platform Port ID
SW1 Eth 0 6 T S WS-C2912-XFas 0/1
R2 Ser 0 136 R 2500 Ser 0
R1#show cdp nei
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater
Device ID Local Intrfce Holdtme Capability Platform Port ID
SW1 Eth 0 0 T S WS-C2912-XFas 0/1
R2 Ser 0 130 R 2500 Ser 0
R1#show cdp nei
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater
Device ID Local Intrfce Holdtme Capability Platform Port ID
R2 Ser 0 126 R 2500 Ser 0
R1#
我们可以从中看到SW1保持时间的变化规律,连续的三个show cdp neighbor命令,看到保持时间是逐步递减的,一直减到0,1秒不差。然后从列表中消失
★ 如何查看单台直连设备的CDP信息。
Show cdp entry R2 pro与show cdp entry R2 ver 分别可以查看设备R2的协议与IOS版本信息,实验步骤与调试如下:
R1#show cdp entry R2 protocol
Protocol information for R2 :
IP address: 10.10.10.2
R1#show cdp entry R2 ver
R1#show cdp entry R2 version
Version information for R2 :
Cisco Internetwork Operating System Software
IOS (tm) 3000 Software (IGS-I-L), Version 11.0(3), RELEASE SOFTWARE (fc1)
Copyright (c) 1986-1995 by cisco Systems, Inc.
Compiled Tue 07-Nov-95 15:04 by deannaw
R1#
查看CDP定时器,用DEBUG动态查看信息收集CDP的组播更新,在启动CDP时是即时发送更新包,还是等到定时器满才发送更新包,更新是从主机名是什么以及哪个接口发送而来的更新,可以从中查获CDP是否正常发送更新数据包。
当我们在SW1上关闭fa 0/1接口时fa 0/1接口就停止了发送CDP更新,但是它却没有机制告诉与它直连的接口禁止发送更新包,因此与交换机直连的路由器始终在定时器满时发送更新。
R1#show cdp entry R2 protocol
Protocol information for R2 :
IP address: 10.10.10.2
R1#show cdp entry R2 ver
R1#show cdp entry R2 version
Version information for R2 :
Cisco Internetwork Operating System Software
IOS (tm) 3000 Software (IGS-I-L), Version 11.0(3), RELEASE SOFTWARE (fc1)
Copyright (c) 1986-1995 by cisco Systems, Inc.
Compiled Tue 07-Nov-95 15:04 by deannaw
R1#
CDP packet info debugging is off
R1#
R1#debug cdp events
CDP events debugging is on