Watch on Instagram

Network Bytes · Episode 35 · CCNA 2.3

CDP and LLDP

Switches learn what's plugged into each port from short hello messages their neighbors send. CDP is Cisco's version; LLDP is the open standard any brand can use.

Posted · About a 1 minute watch, 4 minute read · Take the quiz

The unlabeled wiring closet

Cables in a real wiring closet are often unlabeled or labeled wrong. Without help, finding which switch port leads to which device means tracing wires by hand. Layer 2 discovery protocols solve this: each device tells its directly connected neighbors who it is.

CDP: a name badge every 60 seconds

CDP, the Cisco Discovery Protocol, is on by default on Cisco IOS and IOS XE devices. By default every 60 seconds, each device sends a CDP message out its ports with details such as its device name, model (platform), IP address and the port it's sending from. The neighbor stores this for a holdtime of 180 seconds; if no new message arrives in that time, the entry is dropped.

The "name badge" is an analogy: the real messages are built from small TLV (type-length-value) fields, one per piece of information.

show cdp neighbors

On a Cisco switch, show cdp neighbors lists each neighbor's Device ID, the local interface it's connected to, its platform and its port ID. show cdp neighbors detail adds IP addresses and software versions.

CDP is a Layer 2 protocol, and switches don't forward CDP messages on. So a switch only sees its direct neighbors, one cable away. A switch two hops away never shows up in the list.

LLDP: the open standard

CDP is Cisco's own protocol (a few other vendors' devices can speak it, but you can't count on it). LLDP, the Link Layer Discovery Protocol, is the vendor-neutral standard IEEE 802.1AB and does the same job between devices from any brand. On many Cisco switches, such as the Catalyst 9300, LLDP is off by default and turned on with lldp run; Cisco's LLDP defaults are a 30-second timer and 120-second holdtime. show lldp neighbors shows the results.

Both protocols advertise model, software version and addresses, which also helps an attacker plan. Cisco recommends turning them off on ports facing untrusted devices, per interface (no cdp enable, no lldp transmit / no lldp receive) or for the whole switch (no cdp run, no lldp run).

Try it yourself

In the free Cisco Packet Tracer, connect two Cisco switches and an IP phone, wait a minute, and run show cdp neighbors on one switch: you'll see the other switch and the phone with the local port each one is on. Add a third switch behind the second and run it again: the far switch doesn't appear on the first switch. Then type no cdp enable on one interface and watch that neighbor disappear after the holdtime runs out.

Good to know

  • CDP is Cisco-proprietary (a few other vendors' devices can also speak it, but LLDP is the multi-vendor choice) and enabled by default on Cisco IOS/IOS XE.
  • CDP advertises every 60 seconds by default, with a 180-second holdtime.
  • LLDP is the vendor-neutral IEEE 802.1AB standard; on many Cisco switches (for example Catalyst 9300) it is disabled globally by default and turned on with lldp run, with a 30-second timer and 120-second holdtime.
  • Both are Layer 2 protocols that only reach directly connected neighbors; switches don't forward them on.
  • "Every port" is simplified: they can be turned off globally or per interface, and Cisco recommends doing so on untrusted edge ports because they reveal model, software version and addresses.
  • The "name badge" is an analogy; the real messages are made of TLV fields.

For CCNA learners

This lines up with CCNA 200-301 exam topic 2.3, configure and verify Layer 2 discovery protocols (Cisco Discovery Protocol and LLDP): know what each one shares, that only direct neighbors are seen, and the show cdp neighbors / lldp run commands.

Answer to the comment question

LLDP. CDP is Cisco's own protocol, so a phone from another brand generally won't speak it. LLDP is the vendor-neutral IEEE 802.1AB standard, so the Cisco switches and the other brand's phones can all discover each other with it. On many Cisco switches you'd first turn it on with lldp run.

Test your knowledge

Quick quiz: CDP and LLDP

4 multiple-choice questions. Pick one answer for each, then check how you did.

1What does a switch use CDP messages for?
2By default, how often does a Cisco device send CDP messages?
3SW1 connects to SW2, and SW2 connects to SW3. What does show cdp neighbors on SW1 list?
4Why turn discovery protocols off on ports facing untrusted devices?

Sources

Video transcript

How does a switch find out what's plugged into it?

Picture a wiring closet full of cables, and none of them are labeled. Which port goes to which device? You'd be tracing wires by hand.

Instead, Cisco devices wear name badges. Every sixty seconds, each one sends a short hello out its ports: its name, its model, its IP address, and the port it's using. That's CDP, the Cisco Discovery Protocol.

The neighbor stores that badge. Type show CDP neighbors, and the switch lists who's on each port. It only sees direct neighbors, one cable away.

CDP only works with Cisco gear. LLDP, the open standard, does the same job for any brand. Turn both off on ports facing strangers, though. Name badges help attackers too.

Cisco switches, plus phones from another brand. Which protocol lets them all see each other? Comment your answer below!

That's your byte.

More from Network Bytes

All Network Bytes lessons