Using Cisco Discovery Protocol (CDP)
Cisco
Discovery Protocol (CDP) is a proprietary protocol designed by Cisco to help
administrators collect information about both locally attached and remote
devices.
By
using CDP, you can gather hardware and protocol information about neighbor
devices, which is useful info for troubleshooting and documenting the network.
Getting CDP Timers and Holdtime
Information
The
show cdp command (sh cdp for short) gives you information about two CDP global parameters
that can be configured on Cisco devices:
- CDP timer is
how often CDP packets are transmitted out all active interfaces.
-CDP holdtime is
the amount of time that the device will hold packets received from neighbor
devices.
Both
Cisco routers and Cisco switches use the same parameters.
The
output on the Corp router looks like this:
Corp#sh cdp
Global CDP information:
Sending CDP packets every 60 seconds
Sending a holdtime value of 180 seconds
Sending CDPv2 advertisements is enabled
Use
the global commands cdp holdtime and cdp timer to configure the CDP holdtime and
timer on a router:
Corp(config)#cdp
holdtime ?
<10-255> Length of time (in sec) that receiver must
keep this packet
Corp(config)#cdp
timer ?
<5-254> Rate at which CDP packets are sent (in sec)
You
can turn off CDP completely with the no cdp run command from the
global configuration mode of a router. To turn CDP off or on for an interface,
use the no cdp enable and cdp enable commands.
Gathering Neighbor Information
The
show cdp neighbor command (sh cdp nei for short)
delivers information about directly connected devices. It’s important to
remember that CDP packets aren’t passed through a Cisco switch and that you
only see what’s directly attached. So this means that if your router is
connected to a switch, you won’t see any of the devices hooked up to that
switch.
The
following output shows the show cdp neighbor command used on my ISR router:
Corp#sh cdp neighbors
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
ap Fas
0/1 165 T
I AIR-AP124 Fas 0
R2 Ser
0/1/0 140 R S I 2801 Ser
0/2/0
R3 Ser
0/0/1 157 R S I 1841 Ser
0/0/1
R1 Ser
0/2/0 154 R S I 1841 Ser
0/0/1
R1 Ser
0/0/0 154 R S I 1841 Ser
0/0/0
Corp#
Okay,
we are directly connected with a console cable to the Corp ISR router, and the
router is directly connected to four devices. We have two connections to the R1
router.
Table
5.5 summarizes the information displayed by the show cdp neighbor command for each
device.
TABLE 5 . 5 Output of the show cdp neighbor Command
Field
|
Description
|
Device ID
|
The hostname of the device directly connected.
|
Local Interface
|
The port or interface on which you are receiving the CDP packet.
|
Holdtime
|
The amount of time the router will hold the information before
discarding it if no more CDP packets are received.
|
Capability
|
The capability of the neighbor, such as the router, switch, or
repeater. The capability codes are listed at the top of the command output.
|
Platform
|
The type of Cisco device directly connected.
|
Port ID
|
The neighbor device’s port or interface on which the CDP packets are
multicast.
|
Another
command is the show cdp neighbors detail command (show cdp
nei de for short). This command can be run on both routers and
switches, and it displays detailed information about each device connected
to
the device you’re running the command on. Check out this router output for an
example:
Corp#sh
cdp neighbors detail
Device ID: R2
Entry address(es):
IP address: 10.4.4.2
Platform: Cisco 2801, Capabilities: Router Switch IGMP
Interface: Serial0/1/0, Port ID (outgoing port):
Serial0/2/0
Holdtime : 135 sec
Version :
Cisco IOS Software, 2801 Software
(C2801-ADVENTERPRISEK9-M),
Experimental Version 12.4(20050525:193634) [jezhao-ani 145]
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Fri 27-May-05 23:53 by jezhao
advertisement version: 2
VTP Management
Domain: ‘‘
-------------------------
[output cut]
What
are we being shown here? First, we’re given the hostname and IP address of all directly
connected devices. In addition to the same information displayed by the show
cdp neighbor command (see Table 5.5), the show cdp neighbor detail command
gives us the IOS version of the neighbor device.
Note: Remember that you can see the IP address of only directly
connected devices.
The
show cdp entry * command displays the same information as the show cdp
neighbors detail command. Here’s an example of the router output using the show
cdp entry * command:
Corp#sh
cdp entry *
Device ID: R2
Entry address(es):
IP address: 10.4.4.2
Platform: Cisco 2801, Capabilities: Router Switch IGMP
--More—
[output cut]
There
isn’t any difference between the show cdp neighbors detail and show cdp entry *
commands. However, the sh cdp entry * command has two options that the show cdp
neighbors detail command does not:
Corp#show
cdp entry * protocols
Protocol information for ap :
IP address: 10.1.1.2
Protocol information for R2 :
IP address: 10.4.4.2
Protocol information for R3 :
IP address: 10.5.5.1
Protocol information for R1 :
IP address: 10.3.3.2
Protocol information for R1 :
IP address: 10.2.2.2
the
show cdp entry * protocols command show the IP addresses of each directly
connected neighbor.
The
show cdp entry * version show you only the IOS version of your directly connected
neighbors:
Corp#show
cdp entry * version
Version information for ap :
Cisco IOS Software, C1240 Software (C1240-K9W7-M), Version
12.3(8)JEA, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2006 by Cisco Systems, Inc.
Compiled Wed 23-Aug-06 16:45 by kellythw
Version information for R2 :
Cisco IOS Software, 2801 Software
(C2801-ADVENTERPRISEK9-M),
Experimental Version 12.4(20050525:193634) [jezhao-ani 145]
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Fri 27-May-05 23:53 by jezhao
[output cut]
Although
the show cdp neighbors detail and show cdp entry commands are very similar, the
show cdp entry command allows you to display only one line of output for each directly
connected neighbor, whereas the show cdp neighbor detail command does not. Next,
let’s look at the show cdp traffic command.
Gathering Interface Traffic Information
The
show cdp traffic command displays information about interface traffic,
including the number of CDP packets sent and received and the errors with CDP.
Corp#sh
cdp traffic
CDP counters :
Total packets output: 911, Input: 524
Hdr syntax: 0, Chksum error: 0, Encaps failed: 2
No memory: 0, Invalid packet: 0, Fragmented: 0
CDP version 1 advertisements output: 0, Input: 0
CDP version 2 advertisements output: 911, Input: 524
Corp#
Gathering Port and Interface Information
The
show cdp interface command gives you the CDP status on router interfaces or
switch ports. you can turn off CDP completely on a router by using the no cdp
run command. you can also turn off CDP on interface with the no cdp enable
command. You enable a port with the cdp enable command. All ports
and interfaces default to cdp enable.
On
a router, the show cdp interface command displays information about each interface
using
CDP, including the encapsulation on the line, the timer, and the holdtime for
each interface.
Corp#sh cdp interface
FastEthernet0/0 is administratively down, line protocol is
down
Encapsulation ARPA
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
FastEthernet0/1 is up, line protocol is up
Encapsulation ARPA
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial0/0/0 is up, line protocol is up
Encapsulation HDLC
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
The
above output tells you the interface’s status. To turn off CDP on one interface
on a router, use the no cdp enable command from interface configuration mode:
Corp#config t
Corp(config)#int s0/0/0
Corp(config-if)#no cdp enable
Corp(config-if)#do show cdp interface
that
serial 0/0/0 while not listed in the router output. To get that output, you’d
have to perform a cdp enable on serial 0/0/0. It would then show up in the
output:
Corp(config-if)#cdp
enable
No comments:
Post a Comment