CDP

1. Introduction to CDP

🔍 What is CDP?

Imagine you are connected to a switch (SW1) using a remote connection or console cable, and you don’t know the topology because you don’t have access to a network schema. You want to discover to which devices your switch is connected and through which ports. This is where Cisco Discovery Protocol (CDP) becomes invaluable!

Discovering your network topology using CDP

CDP is a proprietary Layer 2 protocol developed by Cisco. It enables Cisco devices like switches and routers to identify their directly connected neighbors and share information about themselves. With CDP, devices send information about their identity and configuration to connected devices, and in return, they receive similar data about their neighbors.

In our case, by using CDP, SW1 has discovered it is connected to R1.

SW1 discovering R1 by using CDP Cisco Discovery Protocol

And if every device in the network is discovering its neighbors, you can map the entire topology easily.

What is CDP

🛠️ Why Use CDP?

CDP is a foundational tool for network discovery, mapping, and troubleshooting. It’s especially useful when dealing with unknown or undocumented network environments.

🔍 CDP Operation

💬 You might say, “Ok, but how does CDP actually work to gather information about its neighbors?”

CDP operates at Layer 2 (Data Link Layer) of the OSI model and allows Cisco devices to share and collect information about directly connected neighbors. Here’s how it works:

CDP Operation
  1. Sending CDP Advertisements:
    Every Cisco device periodically sends CDP advertisements out of its active interfaces. These advertisements contain essential details about the device, such as:
    • Device ID: The hostname of the device.
    • Interface Information: Details about the port used for the connection.
    • Capabilities: Whether the device is a router, switch, or other type.
    • Platform: The device model or type.
    • IP Address: If configured, the device’s management IP address.
  2. Storing Neighbor Information:
    When a neighboring device receives a CDP advertisement, it extracts the information and stores it in its CDP table. This stored data can be viewed using commands like: 🔹 show cdp neighborsFor example:
    • SW1 sends a CDP advertisement to R1.
    • R1 receives this advertisement, stores the data in its table, and makes it accessible for administrators.
  3. Layer 2 Encapsulation:
    CDP messages are encapsulated within Layer 2 frames. This means they don’t depend on IP connectivity, making CDP effective even in networks where IP addresses are not yet configured.

🔍 CDP Timers

CDP uses timers to ensure that the neighbor information remains accurate and up to date:

CDP Timers
  1. Update Timer:
    By default, CDP sends advertisements every 60 seconds. This regular interval ensures that devices consistently share their information with neighbors. The timer can be adjusted if needed.
  2. Hold Timer:
    Each device sets a hold time for the information it receives. If no updates are received from a neighbor after 180 seconds (default), the neighbor’s information is removed from the CDP table. This prevents outdated or incorrect data from persisting in the network.

3. Configuring CDP

🔍 CDP Overview

CDP is a super helpful protocol that’s enabled by default on all Cisco devices. Let’s imagine you’re at SW1 and you’re curious: “Which devices are connected to my switch?” CDP can give you that answer quickly! Let’s see how to set it up and use it.

Enable CDP Globally

🛠️ Prerequisite: CDP is already turned on by default on Cisco devices. But if someone has turned it off on your devices, you can enable it again using this command:

🔹 Run the following command to turn CDP back on:

SW1(config)# cdp run
CDP Run command to enable cdp

Now that CDP is running, let’s check the neighbors!

🔹 Show connected neighbors:

SW1# 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               Gig 0/0           157              R B             Gig 0/1

What does this mean? Let’s break it down:

  • Device ID: This is the name of the neighbor device (R1). Now you know who you’re connected to.
  • Local Interface: This is the interface on SW1 that connects to the neighbor (GigabitEthernet0/0).
  • Holdtime: If no CDP messages are received for this time (157 seconds), the device is removed from the list.
  • Capability: This shows what the neighbor device can do. Here, R means it’s a router, and B means it can act as a bridge.
  • Platform: The model of the neighbor device (ISR4451).
  • Port ID: The interface on R1 that connects to SW1 (GigabitEthernet0/1).

With just one command, you’ve uncovered some great details about your neighbor!

Getting Detailed Neighbor Information

🔹 Want to learn even more about your neighbors? The detail option can give you deeper insights. Let’s try it:

SW1# show cdp neighbors detail
-------------------------
Device ID: R1
Entry address(es): 
  IP address: 192.168.1.2
Platform: Cisco ,  Capabilities: Router Source-Route-Bridge 
Interface: GigabitEthernet0/0,  Port ID (outgoing port): GigabitEthernet0/1
Holdtime : 135 sec

Version :
Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.5(3)M, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2015 by Cisco Systems, Inc.
Compiled Wed 22-Jul-15 23:04 by prod_rel_team

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


Total cdp entries displayed : 1

**✅ *Let’s break this down into simple points:*

  • Device ID: The name of the neighbor (R1).
  • IP Address: The neighbor’s management IP (192.168.1.2), which you can use to connect to it (e.g., via SSH or Telnet).
  • Platform: The model of the neighbor (Cisco Router).
  • Capabilities: It’s a router (Router) and can act as a bridge (Source-Route-Bridge).
  • Interfaces: Your interface (GigabitEthernet0/0) and the neighbor’s interface (GigabitEthernet0/1).
  • Software Version: The exact IOS version the neighbor is running (IOSv 15.5(3)M). This is useful if you need to troubleshoot software-related issues.

With the detail command, you’ve got all the technical details at your fingertips. It’s great for understanding your network better or preparing for troubleshooting.

Disable CDP Globally

Let’s say you don’t want SW1 to exchange any CDP information with its neighbors. You can stop CDP completely by disabling it globally. This means no neighbor information will be sent or received on any interface.

🔹 To disable CDP globally, use this command:

SW1(config)# no cdp run
Disable CDP Globally

Now, if you try to check for neighbors, you’ll see an error like this:

SW1# show cdp neighbors
% CDP is not enabled

R1 will keep sending CDP information but SW1 won’t accept theses informations.

📢 Why disable it globally? This is useful in environments where you need extra security and don’t want devices revealing any details about themselves. However, this also means you lose the ability to discover neighbors easily, so use it carefully.

4. Enable/Disable CDP on Specific Interfaces

🔍 Why enable/disable CDP per interface?

In many situations, you don’t need to turn off CDP globally but just on certain interfaces. For example:

Best Practices:

  • Enable CDP on uplinks (connections to other switches/routers) so you can discover your network.
  • Disable CDP on user-facing ports to prevent exposing sensitive device information to unauthorized individuals.

This gives you more control and keeps your network secure.

Enable CDP on an Interface

If CDP is globally enabled but turned off on a specific interface, you can enable it again on that interface.

🔹 Example: Let’s enable CDP on GigabitEthernet0/0 (connected to R1).

SW1(config)# interface gigabitethernet 0/0
SW1(config-if)# cdp enable
Enable CDP on an Interface

After enabling CDP, SW1 will start sending and receiving CDP advertisements on GigabitEthernet0/0. This is useful for uplinks or connections to other important devices.

Disable CDP on an Interface

On the other hand, you might want to turn off CDP on specific ports. For example, imagine GigabitEthernet0/1 is connected to a user’s device. You don’t want them to see information about SW1 or its neighbors.

🔹 Here’s how you can disable CDP on that port:

SW1(config)# interface gigabitethernet 0/1
SW1(config-if)# no cdp enable
Disable CDP on an Interface

Why disable CDP on certain interfaces?

  • To protect sensitive information, like the device hostname, platform, and management IP address.
  • To reduce unnecessary network traffic on interfaces that don’t need CDP.

By disabling CDP on user-facing or untrusted interfaces, you make your network more secure without affecting functionality on core links.

5. 📢 Conclusion

🔍 Now that we’ve explored Cisco’s proprietary protocol, CDP, and how it works with Cisco devices, it’s time to move on to the standardized protocol used across multiple vendors: LLDP (Link Layer Discovery Protocol).

Let’s dive in! 🚀