Cisco Discovery Protocol (CDP) is a proprietary protocol designed by Cisco to help in finding information about neighboring devices. Devices connected to each other exchange CDP packets to learn about each other. This can be useful in troubleshooting and documenting the network.
CDP is enabled on all interfaces of all Cisco routers and switches. You can disable CDP globally using the no cdp run command in the global configuration mode. It can be enabled again using the cdp run command. CDP can be disabled on an interface using the no cdp enable command in the interface configuration mode.
Each device running CDP sends out a packet every 60 seconds to its neighbors. The timers associated with CDP on a device can be seen using the show cdp command in the privilege exec mode as shown below:
In the above output you can see that CDP is sending packets every 60 seconds. Each neighbor will keep the information contained in a packet for 180 seconds. The timers can be changed using the cdp timer command and the cdp holdtime command in the global configuration mode as shown below:
As mentioned, earlier CDP can be used to troubleshoot as well as document a network. When you need information regarding devices directly connected to a device, you can check the neighbors learned by CDP using the show cdp neighbor command. An example is shown below:
The output shows that myRouter is directly connect to a device named Switch3. Each column in the output gives information regarding Switch3. Each column is explained below:
- DeviceID – This column gives the hostname of the directly connected device. In this case, the router is directly connected only to a single device named Switch3.
- Local Intrface – This column shows the local interface of the device that is connected to the remote device. In this case, fa0/0 interface of myRouter is connected to Switch3
- Holdtme – This column shows the amount of time in seconds, that the local device will keep the information about the remote device, if no further packets are received from it. In this example, if Switch3 does not send any more CDP packets before 172 seconds, it will be removed from the neighbor table of myRouter. The remote device advertises the holdtime.
- Capability – This column shows the capabilities of the remote device. The meaning of each letter in that column is shown at the beginning of the output. In this example, Switch3 is shown as a Switch and has IGMP enabled on it.
- Platform – This column shows the device model of the remote device. In this output you can see that Switch3 is a Cisco 2960 device.
- Port ID – This column shows the interface number of the remote device that connects to this device. In this example, myRouter is connected to fa0/8 interface of Switch3.
The show cdp neighbor commands provides brief information on all directly connect device. A more detailed information of a neighbor can be see using the show cdp neighbors detail command as shown below:
In the output above you will notice that apart from the information shown by the show cdp neighbor command, this output shows the IOS version, VTP and VLAN information as well as the duplex of the connection to the remote device. This output also shows the IP address of the remote device. This can be very useful if you want to connect to the remote device for troubleshooting. At this stage do not worry about VLAN and VTP. They are covered in the next chapter.
The exact same output can also be seen using the show cdp entry * command. An example of the output is shown below again:
While the output of both show cdp neighbors detail and show cdp entry * are the same, the latter gives you the option to just see the layer 3 protocol information or just the IOS version information from the remote device as shown below:
In the above output, notice that show cdp entry * protocol gives only the IP address (layer 3 information) while show cdp entry * version gives only the IOS version of directly connected devices.
CDP is a simple protocol that just works always. There will hardly be a need to troubleshoot CDP but in case you ever need to do that, you can use the show cdp traffic and show cdp interface commands. The show cdp traffic command displays information regarding the CDP packets sent and received. If CDP traffic is not being sent or received or if there are errors, the output of this command will show that. An example of the output is shown below:
The show cdp interface command on the other hand will show CDP information related to each interface of the device. This command will show you if CDP is enabled on an interface or not and what are the timers associated with each interface. It will also show the status of the interface itself. An example of the output is given below:
One drawback of CDP is that it is a Cisco proprietary protocol and will not work if you have another vendors devices connected to a Cisco device. In such cases, you can use the Link Layer Discovery Protocol (LLDP). LLDP is an open standard protocol that does the same work as CDP but can be used between devices belonging to different vendors.
Not all Cisco devices currently support LLDP and it is not covered in CCNA, but you should know that it could be used in place of CDP.