show cdp neighbors
Discover the topology of directly connected Cisco devices without access to network diagrams.
Definition: show cdp neighbors is a Cisco IOS privileged exec command. Displays information about directly connected Cisco devices discovered via CDP (Cisco Discovery Protocol) including device IDs, local and remote interfaces, holdtime, device capabilities, and platform model.
Overview
The 'show cdp neighbors' command is a fundamental diagnostic tool in Cisco IOS that displays information about directly connected Cisco devices discovered via the Cisco Discovery Protocol (CDP). CDP is a proprietary Layer 2 protocol that runs on all Cisco devices, including routers, switches, and access points, enabling them to advertise their identity, capabilities, and connectivity to neighboring devices. This command is essential for network engineers to verify physical connectivity, discover device types and models, and understand the network topology without requiring direct access to each device.
It is often the first step in troubleshooting connectivity issues, as it confirms whether a device sees its neighbor on a directly connected link. Unlike LLDP (Link Layer Discovery Protocol), which is vendor-neutral, CDP is Cisco-specific and enabled by default on most interfaces. The command provides a concise summary of neighbor device IDs, local interfaces, holdtimes, capabilities, and platform information.
It is particularly useful during initial network deployment, when adding new devices, or when diagnosing Layer 1 or Layer 2 problems. The output is buffered and may not reflect real-time changes immediately; the 'clear cdp table' command can force a refresh. Privileged EXEC mode (enable) is required to execute this command, and it does not affect the running configuration.
Alternatives include 'show cdp neighbors detail' for more granular information, 'show lldp neighbors' for multi-vendor environments, and 'show cdp entry *' to display detailed entries. In a troubleshooting workflow, this command is used early to verify neighbor discovery before moving to more advanced diagnostics like 'show interface' or 'debug cdp packets'.
show cdp neighbors [interface-id] [detail]When to Use This Command
- Identify which Cisco switches or routers are directly connected to each port
- Confirm interface cabling (which local port connects to which remote port)
- Find a device's hostname and model without console access
- Discover IP addresses of directly connected devices using show cdp neighbors detail
Command Examples
Basic CDP neighbours
Router# 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
SW1 Gig 0/0 162 S I WS-C2960X Gig 1/0/1
SW2 Gig 0/1 170 S I WS-C3650 Gig 1/0/1Detail view with IP addresses
Router# show cdp neighbors detail Device ID: SW1 IP address: 192.168.1.2 Platform: cisco WS-C2960X, Capabilities: Switch IGMP Interface: GigabitEthernet0/0, Port ID (outgoing port): GigabitEthernet1/0/1 Holdtime : 162 sec
Understanding the Output
Device ID = hostname of the neighbour. Local Interface = the port on this device. Holdtime = seconds remaining before the entry expires (CDP default: 60s hello, 180s hold).
Capability: R=router, S=switch. Platform = hardware model. Port ID = the neighbour's interface that connects to this device.
Detail view adds the neighbour's management IP.
Configuration Scenarios
Verify CDP Neighbors on a Newly Deployed Switch
A network engineer has just deployed a new Cisco switch (SW2) and connected it to an existing distribution switch (SW1). The goal is to confirm that CDP is working and that SW2 is properly discovering its neighbor.
Topology
SW1(Gi0/1)---10.0.12.0/30---(Gi0/1)SW2Steps
- 1.Step 1: Access SW2 via console or SSH and enter privileged EXEC mode: SW2> enable
- 2.Step 2: Run the command: SW2# show cdp neighbors
- 3.Step 3: Verify that SW1 appears in the output with the correct local interface (GigabitEthernet0/1) and platform (e.g., Cisco 3850).
- 4.Step 4: If no neighbors are shown, check that CDP is enabled globally and on the interface: SW2(config)# cdp run (global) and SW2(config-if)# cdp enable (interface).
! Ensure CDP is enabled globally SW2(config)# cdp run ! Enable CDP on the interface (if not already) SW2(config)# interface GigabitEthernet0/1 SW2(config-if)# cdp enable
Verify: SW2# show cdp neighbors Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone Device ID Local Intrfce Holdtme Capability Platform Port ID SW1 Gig 0/1 172 S I WS-C3850 Gig 0/1
Watch out: CDP is enabled by default on most interfaces, but if the interface is configured with 'no cdp enable', the neighbor will not appear. Always verify CDP status on the specific interface.
Troubleshoot Missing CDP Neighbor After Interface Configuration Change
After changing the duplex and speed settings on an interface connecting two routers (R1 and R2), the CDP neighbor relationship is lost. The engineer needs to verify if CDP is still operational and identify the cause.
Topology
R1(Gi0/0)---10.0.12.0/30---(Gi0/0)R2Steps
- 1.Step 1: On R1, enter privileged EXEC mode: R1> enable
- 2.Step 2: Check CDP neighbors: R1# show cdp neighbors
- 3.Step 3: If R2 is not listed, check the interface status: R1# show interfaces GigabitEthernet0/0
- 4.Step 4: Verify CDP is enabled on the interface: R1# show cdp interface GigabitEthernet0/0
- 5.Step 5: If CDP is disabled, re-enable it: R1(config)# interface GigabitEthernet0/0; R1(config-if)# cdp enable
- 6.Step 6: If the interface is up/up but CDP still fails, check for mismatched MTU or encapsulation that might drop CDP packets.
! Re-enable CDP on the interface R1(config)# interface GigabitEthernet0/0 R1(config-if)# cdp enable ! Optionally, reset CDP table to force refresh R1# clear cdp table
Verify: R1# show cdp neighbors Device ID Local Intrfce Holdtme Capability Platform Port ID R2 Gig 0/0 172 R ISR4331 Gig 0/0 R1# show cdp interface GigabitEthernet0/0 GigabitEthernet0/0 is up, line protocol is up Encapsulation ARPA Sending CDP packets every 60 seconds Holdtime is 180 seconds
Watch out: Changing interface speed or duplex can cause the interface to reset, temporarily disrupting CDP. Also, if the interface is in 'err-disabled' state due to a security violation, CDP will not work. Always check the interface status first.
Troubleshooting with This Command
When using 'show cdp neighbors' for troubleshooting, a healthy output shows one or more neighbor entries with a Device ID, Local Interface, Holdtime (typically 120-180 seconds), Capability codes, Platform, and Port ID. The Holdtime counts down from the configured holdtime (default 180 seconds) and resets with each CDP advertisement (every 60 seconds). If the Holdtime reaches zero, the neighbor entry is removed.
Problem indicators include: no neighbors listed (possible Layer 1 issue, CDP disabled, or incompatible encapsulation), missing expected neighbors (check interface status and CDP configuration), or stale entries (Holdtime not refreshing, indicating CDP packets are being dropped). Focus on the 'Local Intrfce' field to identify which interface the neighbor is connected to; if it shows an unexpected interface, there may be a cabling error. The 'Capability' field indicates device roles (R for router, S for switch, etc.); a mismatch can help identify misconfigured devices.
Common symptoms this command helps diagnose include: complete loss of connectivity (if no CDP neighbors, check physical layer), intermittent connectivity (if neighbors appear and disappear, check for flapping interfaces or duplex mismatches), and incorrect topology (if neighbor appears on wrong interface, trace cables). A step-by-step diagnostic flow: 1) Run 'show cdp neighbors' to see if any neighbors are detected. 2) If none, run 'show cdp interface' to verify CDP is enabled on the expected interface. 3) Check 'show interfaces' for up/up status. 4) If the interface is up but no CDP, check for ACLs blocking CDP (CDP uses multicast MAC 01-00-0c-cc-cc-cc). 5) Use 'debug cdp packets' (with caution) to see if CDP advertisements are being sent or received. Correlate with 'show lldp neighbors' if using multi-vendor, or 'show cdp neighbors detail' for IP addresses and software versions.
Also, 'show cdp traffic' can show packet counts and errors. In scenarios where CDP is disabled globally or per interface, the command will return nothing; re-enable with 'cdp run' or 'cdp enable'. Remember that CDP is a Layer 2 protocol and does not cross routers (unless using CDP over Frame Relay or similar).
For routed links, ensure the interface is not configured with 'no cdp enable'.
CCNA Exam Tips
CCNA exam: CDP is Cisco proprietary and enabled by default on all Cisco interfaces
LLDP is the open standard equivalent
CDP is Layer 2 and works even if IP is not configured
Security recommendation: disable CDP on external-facing interfaces with no cdp enable (per-interface) or no cdp run (globally) to prevent topology information leakage
Common Mistakes
Thinking CDP discovers non-Cisco devices — use LLDP for multi-vendor topology discovery
Not using detail flag to get IP addresses — the basic view does not show management IPs
Forgetting CDP works per-interface — you must be on a port that is physically connected to the neighbour to see it
show cdp neighbors vs show ip arp
Both 'show cdp neighbors' and 'show ip arp' are Layer 2/3 neighbor discovery commands used in troubleshooting, but they operate at different layers and serve distinct purposes. CDP is a Cisco proprietary protocol that discovers directly connected Cisco devices at Layer 2, while ARP maps IP addresses to MAC addresses at Layer 3, often for devices beyond the immediate link.
| Aspect | show cdp neighbors | show ip arp |
|---|---|---|
| Layer of Operation | Layer 2 (Data Link) | Layer 3 (Network) |
| Scope of Discovery | Directly connected Cisco devices only | Any IP host reachable via Ethernet (including non-Cisco) |
| Data Source | CDP cache populated via CDP protocol | ARP cache populated via ARP requests/replies |
| Output Fields | Device ID, Local Intf, Holdtime, Capability, Platform, Port ID | IP address, MAC address, Age (in ARP cache), Interface |
| Dependency | Requires CDP enabled globally/per interface | Works automatically; no protocol enablement needed |
| Typical Use Case | Mapping network topology and verifying neighbor adjacency | Troubleshooting IP connectivity and resolving Layer 2 addresses |
Use show cdp neighbors when you need to verify directly connected Cisco devices and their interface mappings for topology discovery.
Use show ip arp when you need to resolve a known IP address to its MAC address or check the IP-to-MAC mapping for a specific interface.
Platform Notes
In IOS-XE (e.g., Catalyst 9000 switches, ISR 4000 routers), the 'show cdp neighbors' command syntax and output are nearly identical to classic IOS. However, IOS-XE may include additional capability codes (e.g., 'I' for IGMP, 'r' for Repeater) and the output format is slightly more tabular. On NX-OS (e.g., Nexus switches), the equivalent command is 'show cdp neighbors' as well, but the output includes a 'System Name' field instead of 'Device ID', and the 'Platform' field may show more detailed model information.
NX-OS also supports 'show cdp neighbors detail' for extended info. On ASA firewalls, CDP is not supported; instead, use 'show lldp neighbors' if LLDP is enabled. For IOS-XR (e.g., ASR 9000), CDP is not available; the equivalent is 'show lldp neighbors' or 'show cdp neighbors' is not supported.
Between IOS versions (12.x, 15.x, 16.x), the command behavior is consistent, but newer versions may include additional capability codes (e.g., 'P' for Phone). In IOS 15.x and later, CDP is enabled by default on all interfaces, but some platforms (like Catalyst 2960-X) may have CDP disabled globally by default in certain software images. Always verify with 'show cdp' to see global status.
On IOS-XE 16.x, the output may include a 'VTP Domain' field if VTP is configured. For multi-vendor environments, consider using LLDP instead, but CDP remains the go-to for pure Cisco networks.
Related Commands
show interfaces
Displays detailed Layer 1 and Layer 2 statistics for all interfaces or a specific interface: line protocol state, hardware type, MAC address, MTU, bandwidth, duplex, speed, input/output rates, error counters, and queue statistics.
show ip arp
Displays the ARP cache mapping IP addresses to MAC addresses, the age of each entry, and the interface through which the host is reachable.
show ip interface brief
Displays a one-line summary of all interfaces showing the IP address assigned, operational status (up/down), and line protocol status. The fastest way to get a device health overview.
Practice for the CCNA 200-301
Test your knowledge with practice questions covering all CCNA 200-301 exam domains.
Practice CCNA 200-301 Questions