12.4.1 实验1:配置CDP
1、实验目的
通过本实验可以掌握:
- CDP特征。
- CDP配置和调试方法。
- 通过CDP查看设备直连邻居信息的方法。
2、实验拓扑

配置CDP的实验拓扑如上图所示。
3、实验步骤
(1)配置路由器R1
R1(config)#interface serial 0/3/0
R1(config-if)#ip address 172.16.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface gigabitEthernet 0/0
R1(config-if)#ip address 172.16.1.1 255.255.255.0
R1(config-if)#no shutdown 
R1(config-if)#exit
R1(config)#(2)配置路由器R2
R2(config)#interface serial 0/3/0
R2(config-if)#ip address 172.16.12.2 255.255.255.0
R2(config-if)#no shutdown 
R2(config-if)#exit(3)配置交换机S1
S1(config)#interface vlan 1
S1(config-if)#ip address 172.16.1.100 255.255.255.0
S1(config-if)#no shutdown 
S1(config-if)#exit4、实验调试
(1)查看CDP运行的信息
R1#show cdp                      //查看CDP运行的信息
Global CDP information:Sending CDP packets every 60 secondsSending a holdtime value of 180 secondsSending CDPv2 advertisements is enabled
R1#以上输出表明默认时CDP是运行的,每60秒从接口发送CDP消息,以太网中该消息是IEEE 802.3帧,目的MAC地址为0100.0ccc.ccee组播地址。邻居收到CDP消息后会放入自己的CDP表中,并保存180秒,当前使用CDP版本2。
(2)查看接口CDP的运行情况
R1#show cdp interface gigabitEthernet 0/0        //查看接口的CDP运行情况
GigabitEthernet0/0 is up, line protocol is upSending CDP packets every 60 seconds           //CDP发送间隔Holdtime is 180 seconds                        //CDP维持时间
R1#(3)查看设备直连邻接CDP的信息
R1#show cdp neighbors               //查看设备直连邻居CDP的信息
Capability Codes: R - Router, T - Trans Bridge, B - Source Route BridgeS - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID    Local Intrfce   Holdtme    Capability   Platform    Port ID
R2           Ser 0/3/0        155            R       C2900       Ser 0/3/0
S1           Gig 0/0          145                    3650        Gig 1/0/1
R1#以上输出表明路由器R1有2个 CDP邻居:R2和S1,各字段的含义如下所述。
- Device ID:表示CDP邻居的王机名。
- Local Interface:本地接口,表示Rl通过自己哪个接口和 CDP邻居连接。
- Holdtme:指收到邻居发送的CDP消息以来的有效时间,米用从180杪倒计时。
- Capability:表示邻居的设备类型及其功能,输出的前三行Capability Codes对各代码进行了说明。
- Platform:表示邻居设备的硬件型号。
- Port ID:端口ID,表示R1是连接对方设备的哪个接口上。
(4)查看设备直连CDP邻居的详细信息
R2#show cdp neighbors detail       //查看设备直连CDP邻居的详细信息Device ID: R1                      //邻居的主机名
Entry address(es):                 //接口IP地址IP address : 172.16.12.1
Platform: cisco C2900, Capabilities: Router
Interface: Serial0/3/0, Port ID (outgoing port): Serial0/3/0
Holdtime: 169Version :
Cisco IOS Software, C2900 Software (C2900-UNIVERSALK9-M), Version 15.1(4)M4, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2012 by Cisco Systems, Inc.
Compiled Thurs 5-Jan-12 15:41 by pt_teamadvertisement version: 2       //CDP通告的版本
Duplex: fullR2#【提示】
show cdp neighbors detail命令和show cdp entrv *命令功能一样.后者的*可以是设备片体的名字.clear cdp table命令可以清除CDP表项。
(5)关闭与CDP以及CDP参数调整
R1(config)#interface gigabitEthernet 0/0
R1(config-if)#no cdp enable 
R1(config-if)#exit
R1(config)#no cdp run
R1(config)#cdp run
R1(config)#cdp timer 10   
R1(config)#cdp holdtime 30
R1(config)#exit(6)查看CDP流量情况
R1#show cdp traffic