Previous section   Next section

Recipe 2.4 Using the Cisco Discovery Protocol

2.4.1 Problem

You want to see summary information about what is connected to your router's interfaces.

2.4.2 Solution

You can selectively enable or disable Cisco Discovery Protocol (CDP) on the entire router, or on individual interfaces:

Router1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router1(config)#cdp run
Router1(config)#interface Serial0/0
Router1(config-if)#cdp enable
Router1(config-if)#exit
Router1(config)#interface FastEthernet0/0
Router1(config-if)#no cdp enable
Router1(config-if)#exit
Router1(config)#interface FastEthernet1/0
Router1(config-if)#cdp enable
Router1(config-if)#end
Router1#

2.4.3 Discussion

CDP is enabled by default on the router, and on all interfaces. If you have previously disabled it (as discussed in Recipe 2.5) and want to reenable CDP on the router, you can issue the cdp run global configuration command:

Router1(config)#cdp run

This turns on CDP processing on all supported interfaces by default. If you don't want to run CDP on a particular interface, you can use the no cdp enable command:

Router1(config)#interface Serial0/0
Router1(config-if)#no cdp enable

CDP is a Cisco proprietary protocol that allows Cisco devices to identify one another and exchange useful identifying information. The show cdp neighbors command gives a summary of information about adjacent devices that also happen to be running CDP:

Router1#show 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
Router2          Ser 0/0            179          R        2621      Ser 0/1
Switch1          Fas 1/0            152         T S       WS-C2924  2/2
Router1#

As you can see, this output tells you the name and type of device of each neighbor, including the model number. It also includes both the interface on this router that connects to each neighbor, and the corresponding interface on the neighbor device.

The last of the devices listed is actually a Cisco Catalyst Ethernet switch. This points out one of the most useful features of CDP. While other mechanisms such as the ARP cache, routing protocols, or simple ping tests can tell you things about the Layer 3 neighbors, CDP gives you information about the Layer 2 neighbors. This is true even when a Layer 2 neighbor has no configured IP addresses.

You can see additional information about these neighboring devices by adding the detail keyword:

Router1#show cdp neighbors detail
-------------------------
Device ID: Router2
Entry address(es): 
  IP address: 10.1.1.2
Platform: cisco 2621,  Capabilities: Router 
Interface: Serial0/0,  Port ID (outgoing port): Serial0/1
Holdtime : 136 sec
   
Version :
Cisco Internetwork Operating System Software 
IOS (tm) C2600 Software (C2600-IK9O3S-M), Version 12.2(13), RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2002 by cisco Systems, Inc.
Compiled Tue 19-Nov-02 22:27 by pwade
   
advertisement version: 2
   
Device ID: Switch1
Entry address(es): 
  IP address: 172.25.1.4
Platform: WS-C2924,  Capabilities: Trans-Bridge Switch 
Interface: FastEthernet1/0,  Port ID (outgoing port): FastEthernet0/12
Holdtime : 116 sec
          
Version :
Cisco Internetwork Operating System Software 
IOS (tm) C2900XL Software (C2900XL-C3H2S-M), Version 12.0(5)WC3b, RELEASE SOFTWARE 
(fc1)
Copyright (c) 1986-2002 by cisco Systems, Inc.
Compiled Fri 15-Feb-02 10:14 by antonino
   
advertisement version: 2
Duplex: full
   
Router1#

This output tells you the IP addresses of the adjacent interfaces on the neighbor devices and gives details about the Cisco IOS or CatOS version.

Both of these neighbor devices support CDP Version 2, which Cisco introduced in IOS Version 12.0(3)T. It includes three new fields that are quite useful on LANs: VTP Domain Name, 802.1Q Native VLAN, and duplex configuration. As you can see in the previous output, the router and switch agree that they are operating at full duplex. Please refer to Chapter 16 for discussions of both 802.1Q and Ethernet Duplex configuration.

This new duplex option is extremely useful because the router and switch can now automatically detect duplex mismatches. We can demonstrate this ability by deliberately creating a duplex problem: in the following example, we change the switch's setting to half duplex for the port facing router. The router was able to detect the problem through CDP and issue the following log message:

Feb  6 11:36:11: %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered on 
FastEthernet1/0 (not half duplex), with 003541987 (switch) FastEthernet0/12 (half
duplex).

CDP Version 2 is enabled by default on all IOS versions 12.0(3)T and higher. To globally disable Version 2 support on a router and allow only Version 1, issue the following global configuration command:

Router1(config)#no cdp advertise-v2

However, it is not entirely clear what purpose this would serve. We know of no interoperability problems between CDP Version 1 and Version 2. While there are security problems, which we will discuss in Recipe 2.5, they are better addressed by disabling CDP altogether.

You can see global information about the router's CDP configuration with the show cdp command:

Router1#show cdp
Global CDP information:
        Sending CDP packets every 60 seconds
        Sending a holdtime value of 180 seconds
        Sending CDPv2 advertisements is  enabled
Router1#

Here you can see that this router sends out CDP advertisement packets every 60 seconds, which is the default. The holdtime parameter is the length of time that the router will wait to hear the next CDP advertisement from one of its neighbors. If it doesn't receive this advertisement packet within this time period, the router flushes the corresponding entry from its CDP neighbor table.

You can adjust these parameters globally for the entire router as follows:

Router1(config)#cdp timer 30
Router1(config)#cdp holdtime 240

Both of these commands accept an argument in seconds. The advertisement timer can have any value between 5 and 254 seconds, while the holdtimer must be between 10 and 255 seconds.

2.4.4 See Also

Recipe 2.5; Chapter 16


  Previous section   Next section
Top