How to Configure And Verify CDP in Cisco Devices

CDP is a Cisco proprietary Layer 2 discovery protocol used to share information with and discover information about neighboring devices. The shared information includes hostname, IP address, device type, etc. Because this protocol shares information about devices in the network, it is considered a security risk and is often not used.

CDP is enabled on Cisco devices by default. For example, Cisco routers, switches, firewalls, etc., have it enabled by default. CDP messages are periodically sent to the multicast address 0100.0ccc.cccc. CDP messages are not forwarded to other devices; when a device receives CDP messages, it processes and discards them.

By default, CDP messages are sent every 60 seconds on all interfaces that are in the up state. Additionally, the default CDP hold time is 180 seconds; if a message is not received from a neighbor after 180 seconds, that neighbor is deleted from the CDP neighbor table.

There are two versions of CDP: Version 1 and Version 2. However, Version 2 is used by default.

Network topology

The network topology we will be making use of in this post is shown below. As you can see, it consists of two routers and a cloud symbol that stands for internet. In this demonstration, we will be enabling and disabling CDP on the two routers and then using the appropriate show command to view the CDP-neighbor relationship.

network topology for CDP configuration

How to Enable CDP on Cisco Device

By default, CDP (Cisco Discovery Protocol) is enabled on any Cisco device. However, if it’s disabled for some reason, you can enable it globally by entering the command “cdp run” in global configuration mode. This command activates CDP on all interfaces that are in the up state. To enable CDP on a specific interface, enter the interface configuration mode and run ‘cdp enable’.

For instance, to enable CDP on all the interfaces of the routers that are up, I will run the command below in the global configuration mode of the router.

R1(config)#cdp run

To enable CDP on the  ethernet0/1 interface, I will run the following command;

R1(config)#interface ethernet0/1
R1(config-if)#cdp enable

How to Disable CDP On Cisco Devices

When CDP is enabled, you can disable CDP globally on the device by running ‘no cdp run’ from global configuration mode. To disable CDP on a specific interface, enter interface configuration mode and then use the command ‘no cdp enable’.

On Router 1

R1(config)#no cdp run --Disable CDP on all interfaces
R1(config-if)#no cdp enable ---> disable CDP on a specific interface

How To Configure CDP Timer

To configure CDP Timer in seconds, enter the following command on the CLI of the network devices;

R1(config)# cdp timer <seconds> 

How to Configure CDP Hello Timer

To configure CDP Hello timer, enter the following command on the CLI of the Cisco devices

R1(config)# cdp holdtime <seconds> 

CDP Show Commands

There are a variety of CDP show commands to verify the CDP neighbor relationship between two network devices running CDP. We will go through them one-by-one.

1. Show cdp

The “show cdp” command displays information about CDP hello time, hold time and the version of CDP running. Here is the output of “show cdp” command on R1.

R1#show cdp

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

2. show cdp interface

The “show cdp interface” command displays information about the interfaces of network devices that have CDP enabled. When an interface is shut down, CDP will automatically be disabled on that interface. When CDP is disabled on an interface, the interface will not appear on the output of  “show cdp interface” command. Below are the output of the show cdp interface command on R1.

CDP disabled on the e0/1 interface

R1(config)#interface ethernet0/1     
R1(config-if)#ip address 10.254.4.70 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#no cdp enable
R1(config-if)#exit

Check CDP on all interfaces. (ethernet0/1 will not be displayed as CDP was explicitly disabled on it in previous command.)

R1#show cdp interface

Ethernet0/0 is administratively down, line protocol is down
  Encapsulation ARPA
  Sending CDP packets every 60 seconds
  Holdtime is 180 seconds
Ethernet0/2 is administratively down, line protocol is down
  Encapsulation ARPA
  Sending CDP packets every 60 seconds
  Holdtime is 180 seconds
Ethernet0/3 is administratively down, line protocol is down
  Encapsulation ARPA
  Sending CDP packets every 60 seconds
  Holdtime is 180 seconds cdp enabled interfaces : 3
 interfaces up          : 0
 interfaces down        : 3

Enable the interface ethernet0/0 on R1. After enabling the interface, CDP will be enabled automatically on the interfaces because CDP is enabled by default on interfaces of Cisco network devices.

R1(config)#interface ethernet0/0
R1(config-if)#no shutdown 
R1(config-if)#exit

R1#show cdp interface

Ethernet0/0 is up, line protocol is up 		<-- CDP on ethernet0/0 is up.
  Encapsulation ARPA
  Sending CDP packets every 60 seconds
  Holdtime is 180 seconds
Ethernet0/2 is administratively down, line protocol is down
  Encapsulation ARPA
  Sending CDP packets every 60 seconds
  Holdtime is 180 seconds
Ethernet0/3 is administratively down, line protocol is down
  Encapsulation ARPA
  Sending CDP packets every 60 seconds
  Holdtime is 180 seconds

 cdp enabled interfaces : 3
 interfaces up          : 1	<--
 interfaces down        : 2

 

3. show CDP interface [interface_ID]

The “show CDP interface [interface_ID]” displays whether CDP is enabled on a specific interface. If it is enabled, it displays much CDP information about the interface. If it is not enabled, it indicates that CDP is not enabled on the specific interface.

Check the CDP status on ethernet0/1 (note that CDP was disabled on this interface before).

R1#show cdp interface ethernet0/1

 CDP is not enabled on interface Ethernet0/1

On Router2

Enable the interface ethernet0/0 on R2

R2(config)#interface ethernet0/0
R2(config-if)#no shutdown
R2(config-if)#exit
R2#show cdp interface
Ethernet0/0 is up, line protocol is up <-- CDP on ethernet0/0 is up.
Encapsulation ARPA
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Ethernet0/1 is administratively down, line protocol is down
Encapsulation ARPA
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Ethernet0/2 is administratively down, line protocol is down
Encapsulation ARPA
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Ethernet0/3 is administratively down, line protocol is down
Encapsulation ARPA
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
cdp enabled interfaces : 4
interfaces up : 1
interfaces down : 3

4. show cdp neighbors

This command displays the list of CDP neighbors

On Router1

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, 
                  D - Remote, C - CVTA, M - Two-port Mac Relay 

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
R2               Eth 0/0           154              R B   Linux Uni Eth 0/0

Total cdp entries displayed : 1</code

>

On Router2

R2#show cdp neighbors 
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone, 
                  D - Remote, C - CVTA, M - Two-port Mac Relay 

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
R1               Eth 0/0           157              R B   Linux Uni Eth 0/0

Total cdp entries displayed : 1

5. show cdp neighbors detail

This command displays more detail about CDP neighbors

R1#show cdp neighbors detail 
-------------------------
Device ID: R2 		<--
Entry address(es): 
Platform: Linux Unix,  Capabilities: Router Source-Route-Bridge 
Interface: Ethernet0/0,  Port ID (outgoing port): Ethernet0/0
Holdtime : 136 sec

Version : <--
Cisco IOS Software, Linux Software (I86BI_LINUX-ADVENTERPRISEK9-M), Version 15.7(3)M2, DEVELOPMENT TEST SOFTWARE
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2018 by Cisco Systems, Inc.
Compiled Wed 28-Mar-18 11:18 by prod_rel_team

advertisement version: 2


Total cdp entries displayed : 1

On Router2


R2#show cdp neighbors detail
-------------------------
Device ID: R1		<--
Entry address(es): 
  IP address: 10.254.4.70
Platform: Linux Unix,  Capabilities: Router Source-Route-Bridge 
Interface: Ethernet0/0,  Port ID (outgoing port): Ethernet0/0
Holdtime : 124 sec

Version : <--
Cisco IOS Software, Linux Software (I86BI_LINUX-ADVENTERPRISEK9-M), Version 15.7(3)M2, DEVELOPMENT TEST SOFTWARE
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2018 by Cisco Systems, Inc.
Compiled Wed 28-Mar-18 11:18 by prod_rel_team

advertisement version: 2
Management address(es): 
  IP address: 10.254.4.70


Total cdp entries displayed : 1

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top