CCNA Lab 10: Network Discovery β CDP, LLDP, and Layer 2 Topology Mapping
CDP (Cisco Discovery Protocol) and LLDP (Link Layer Discovery Protocol) advertise device identity and capabilities to directly connected neighbors. They are your best tools for building a Layer 2 topology map without getting up from your desk.
CDP is Cisco proprietary and enabled by default on all Cisco IOS interfaces. It sends advertisements every 60 seconds to the multicast address 01:00:0c:cc:cc:cc.
! Enable CDP globally (default)
cdp run
! Disable CDP globally
no cdp run
! Enable CDP on a specific interface (default for all)
interface Gi0/1
cdp enable
! Disable CDP on an interface
interface Gi0/1
no cdp enableshow cdp
show cdp interface
show cdp neighbors
show cdp neighbors detail
show cdp entry *
show cdp trafficshow cdp neighbors provides a table of directly connected devices:
Device ID Local Intf Holdtme Capability Platform Port ID
ACCESS-SW-2 Gi0/24 157 S WS-C2960 Gi0/24
CORE-SW Gi0/23 176 S I WS-C3850 Gi1/0/1
ROUTER-1 Gi0/22 143 R ISR-4331 Gi0/0/0
Capability codes: R = Router, S = Switch, I = IGMP, T = Trans bridge.
show cdp neighbors detailReturns the full detail including IP address, platform, IOS version, and native VLAN:
-----------------------
Device ID: CORE-SW
Entry address(es):
IP address: 192.168.1.1
Platform: cisco WS-C3850-24T, Capabilities: Switch IGMP
Interface: GigabitEthernet0/23, Port ID (outgoing port): GigabitEthernet1/0/1
Holdtime: 176 sec
Version:
Cisco IOS Software, IOS-XE Software (Cat3k-CAA-UNIVERSALK9-M)
Version 16.12.5
advertisement version: 2
VTP Management Domain: ''
Native VLAN: 99
Duplex: full
This is invaluable for inventory documentation without logging into every device.
LLDP is the IEEE standard (802.1AB) and works with any vendor. It is disabled by default on Cisco IOS.
! Enable LLDP globally
lldp run
! Enable LLDP transmit/receive on an interface
interface Gi0/1
lldp transmit
lldp receive
! Disable on interface
interface Gi0/1
no lldp transmit
no lldp receiveshow lldp
show lldp interface
show lldp neighbors
show lldp neighbors detail
show lldp traffic
show lldp entry *LLDP neighbor output:
Device ID: DIST-SW-MDF-01
Local Intf: Gi0/24
Chassis id: aabb.ccdd.eeff
Port id: Gi0/24
Port Description: GigabitEthernet0/24
System Name: DIST-SW-MDF-01
System Description: Cisco IOS Software, C3560 Software (C3560-IPBASEK9-M)
Time remaining: 107 seconds
Hold Time: 120 sec
Capabilities: Bridge, Router
Management Addresses:
IPv4: 192.168.1.5
ssh CORE-SW "show cdp neighbors detail" > cdp-core.txt
ssh DIST-SW-1 "show cdp neighbors detail" > cdp-dist1.txt
ssh DIST-SW-2 "show cdp neighbors detail" > cdp-dist2.txtThe critical fields for each neighbor entry:
| Field | Example |
|---|---|
| Device ID | ACCESS-SW-2 |
| Local Interface | GigabitEthernet0/24 |
| Neighbor Interface | GigabitEthernet0/24 |
| IP Address | 192.168.1.2 |
| Platform | WS-C2960 |
| Native VLAN | 99 |
A valid connection must be confirmed from both sides. If CORE-SW shows ACCESS-SW-2 via Gi0/24, ACCESS-SW-2 must show CORE-SW via Gi0/24. Mismatches mean cabling errors.
Build a simple text adjacency list:
CORE-SW
ββ Gi0/23 ββ DIST-SW-1 (Gi0/24)
ββ Gi0/24 ββ DIST-SW-2 (Gi0/24)
DIST-SW-1
ββ Gi0/1 ββ ACCESS-SW-1 (Gi0/24)
ββ Gi0/2 ββ ACCESS-SW-2 (Gi0/24)
ββ Gi0/24 ββ CORE-SW (Gi0/23)
! On Switch A
show cdp neighbors Gi0/24 detail | include Device ID|Port ID
! On Switch B
show cdp neighbors Gi0/24 detail | include Device ID|Port IDIf the Device ID or Port ID does not match expectations, the cable is patched wrong.
CDP reveals device model and capabilities. A βLinuxβ or βWindowsβ device showing up as a CDP neighbor on a trunk port is a red flag.
CDP reports native VLAN mismatch as a separate notification:
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/24
But you can also see it in show cdp neighbors detail output β compare the native VLAN field on both ends.
show cdp interface Gi0/24CDP reports the interface speed and duplex. If one end reports full duplex and the other half, you have a mismatch.
interface range Gi0/1-22
no cdp enable
no lldp transmit
no lldp receiveCDP/LLDP leak device type, IOS version, IP addresses, and native VLANs. Attackers use this information for targeted exploits.
Some organizations disable CDP/LLDP entirely on external-facing or DMZ switches.
| Feature | CDP | LLDP |
|---|---|---|
| Standard | Cisco proprietary | IEEE 802.1AB |
| Multi-vendor | Cisco only | Any |
| Default on Cisco IOS | Enabled | Disabled |
| Advertisement interval | 60 sec | 30 sec (configurable) |
| Hold time multiplier | 3 | 4 |
| TLV information | Device, platform, IP, VLAN, duplex | Device, system desc, management IP, capabilities, more |
| Security | Leaks Cisco info | Leaks vendor-neutral info |
#!/bin/bash
# Quick topology dump β run from a management host
SWITCHES="CORE-SW DIST-SW-1 DIST-SW-2 ACCESS-SW-1 ACCESS-SW-2"
for switch in $SWITCHES; do
echo "=== $switch ==="
ssh $switch "show cdp neighbors detail" 2>/dev/null || echo "Unreachable"
echo ""
doneFor a more structured output, parse with:
ssh CORE-SW "show cdp neighbors detail" | grep -E "Device ID:|Interface:|Port ID|IP address|Platform"| Command | Purpose |
|---|---|
show cdp neighbors | List directly connected Cisco devices |
show cdp neighbors detail | Full device info (IP, IOS, platform, VLAN) |
show cdp entry * | Same as detail for all neighbors |
show cdp interface | CDP status per interface |
show cdp traffic | CDP packet statistics |
show lldp neighbors | List LLDP neighbors |
show lldp neighbors detail | Full LLDP neighbor info |
show lldp interface | LLDP status per interface |
show lldp traffic | LLDP packet statistics |
cdp run / no cdp run | Enable/disable CDP globally |
lldp run / no lldp run | Enable/disable LLDP globally |
Related Articles
CCNA Lab 10: Network Discovery β CDP, LLDP, and Layer 2 Topology Mapping
Use CDP and LLDP to discover connected devices, verify cabling, and build accurate Layer 2 topology maps without leaving the CLI.
CCNA Lab 14: Network Health Checks, BKMs, and Command Reference
Daily, weekly, and monthly health checks for your switches. Best known methods, maintenance procedures, and a comprehensive command reference for L2 engineers.
CCNA Lab 12: DHCP Snooping, DAI, and IP Source Guard
Configure Layer 2 security features to prevent DHCP spoofing, ARP poisoning, and IP spoofing attacks on your access switches.