LLDP vs CDP: Layer 2 Discovery Protocols Compared - 夜莺博客

LLDP vs CDP: Layer 2 Discovery Protocols Compared

Every switch you have ever managed runs some form of neighbor discovery, and the protocol choice says a lot about your vendor mix: Cisco CDP is proprietary and rich, while LLDP is the IEEE 802.1AB open standard that any vendor's gear can speak. Both operate at Layer 2 and both answer the same operational questions — what is connected to this port, and what is its platform, software and capability? This guide compares how they work, how to configure and verify them, and how to keep them from becoming a reconnaissance tool.

Protocol Fundamentals

  • LLDP — IEEE 802.1AB standard, supported across all vendors (Cisco, Juniper, Arista, Huawei, HPE, Mellanox and open source). Sends Type-Length-Value (TLV) frames with chassis ID, port ID, system name, capabilities and management address. Extensible — LLDP-MED adds VoIP and PoE information.
  • CDP — Cisco proprietary, but widely supported by other vendors for compatibility (many HP/HPE and Polycom devices answer CDP). Carries device ID, port ID, platform, software version and native VLAN. Frames are multicast at Layer 2.

The practical difference: CDP gives you a slightly richer device picture (including the native VLAN and duplex state) but LLDP is the safe default in a mixed environment because it is standards-based and more extensible. The Cisco Learning Network discussion of LLDP versus CDP summarises the trade-off well: choose LLDP for interoperability and detail, keep CDP where Cisco-only features need it.

Timers and Behavior

Both protocols send periodic advertisements and expire neighbors that stop advertising. CDP defaults to a 60-second timer with a 180-second hold time; LLDP uses a 30-second timer with a 120-second hold time on most platforms. Because the two protocols are independent, switches run them side by side — a Cisco switch facing a Cisco access switch usually exchanges both.

Configuration and Verification

! Cisco IOS - LLDP is off by default
Switch(config)# lldp run
Switch# show lldp neighbors
Switch# show lldp neighbors detail
Switch# show lldp interface GigabitEthernet1/0/1
Switch# show lldp traffic
! Cisco IOS - CDP is on by default
Switch# show cdp neighbors
Switch# show cdp neighbors detail
Switch# show cdp entry *
Switch(config)# no cdp run
Switch(config-if)# no cdp enable

On Junos both are configured at the interface level under protocol lldp and protocol cdp, with show lldp neighbors and show cdp neighbors as the operational views. The single most useful habit: when a port shows an unexpected neighbor, show lldp neighbors detail (or cdp entry) usually reveals the platform, software version and management address of whatever is plugged in.

Security: Disable Where You Do Not Need It

Discovery protocols leak topology information — every frame advertises your device names, models and software versions to anyone on the segment. Best practice from both Cisco and general hardening guides: enable LLDP/CDP only on ports that genuinely need neighbor discovery (interswitch links, VoIP segments) and disable them on untrusted edge ports, internet-facing segments and guest networks. If you must run them, treat CDP as the higher-risk option since it advertises more operational detail. A comparison of other monitoring and discovery protocols on the network appears in our sFlow vs NetFlow vs IPFIX article, and multi-vendor command patterns are in the multi-vendor CLI cheat sheet.

原文链接:https://ipcisco.com/lesson/lldp-versus-cdp/