Objective

The Cisco Discovery Protocol (CDP) is a protocol used by Cisco devices to share device information with other connected Cisco devices. This includes type of device, firmware version, IP address, serial number, and other identifying information. CDP settings can be adjusted globally or on an individual port basis on the switch.

Similar to Link Layer Discovery Protocol (LLDP), CDP is a link layer protocol for directly connected neighbors to advertise themselves and their capabilities to each other. However, unlike LLDP, CDP is a Cisco proprietary protocol.

This article provides instructions on how to configure CDP settings on a switch through the Command Line Interface (CLI) which covers the following workflow:

1. Configure CDP Global Properties.

2. Configure CDP Settings on a Interface.

3. (Optional) If Auto Smartport is used to detect the capabilities of CDP devices, configure CDP settings on the Smartport properties. For instructions, click here.

4. Display or Clear the CDP Settings

If you prefer to configure CDP settings using the Graphical User Interface (GUI), click here.

Applicable Devices

- Sx350 Series

- SG350X Series

- Sx500 Series

- Sx550X Series

Software Version

- 2.3.0.130

Configure CDP Properties

Configure CDP Global Properties

Step 1. Log in to the switch console. The default username and password is cisco/cisco. If you have configured a new username or password, enter the credentials instead.

Note: To learn how to access an SMB switch CLI through SSH or Telnet, click here.

Note: The commands may vary depending on the exact model of your switch. In this example, the SG350X switch is accessed through Telnet. SSH is recommended.

Step 2. From the Privileged EXEC mode of the switch, enter the Global Configuration mode by entering the following:

SG350X#configure

Step 3. To globally enable CDP on the switch, enter the following:

SG350X(config)#cdp run

Note: CDP is enabled by default.

Step 4. (Optional) To specify CDP packets handling when CDP is globally disabled, enter the following:

SG350X(config)#cdp pdu [filtering | bridging | flooding]

The options are:

- filtering — Specifies that when CDP is globally disabled, CDP packets are filtered or deleted.

- bridging — Specifies that when CDP is globally disabled, CDP packets are bridged as regular data packets and forwarded based on the Virtual Local Area Network (VLAN).

- flooding — Specifies that when CDP is globally disabled, CDP packets are flooded to all the ports in the product that are in STP forwarding state, ignoring the VLAN filtering rules.

Step 5. To enable the device to advertise the voice VLAN in CDP on all of the ports that are CDP enabled and are member of the voice VLAN, enter the following:

SG350X(config)#cdp appliance-tlv enable

Note: This will enable sending of the Appliance TLV.

Step 6. To validate that all mandatory (according to the CDP protocol) TLVs are present in received CDP frames, enter the following:

SG350X(config)#cdp mandatory-tlvs validation

Note: If enabled, incoming CDP packets not containing the mandatory TLVs are discarded and the invalid error counter is incremented. This will delete CDP packets which do not contain all the mandatory TLVs.

Step 7. To specify version 2 of transmitted CDP packets, enter the following:

SG350X(config)#cdp advertise-v2

Note: In this example, version 2 is used.

Step 8. To specify Time-to-Live (TTL) value into sent CDP messages, enter the following:

SG350X(config)#cdp holdtime [seconds]

- seconds — Value of the Time-to-Live hold time in seconds. The value should be greater than the value of the Transmission Timer.

Note: This is the amount of time that CDP packets are held before the packets are discarded, measured in multiples of the TLV Advertise Interval. For example, if the TLV Advertise Interval is 30 seconds, and the Hold Multiplier is 4, then the CDP packets are discarded after 120 seconds. The default value is 180 seconds. In this example, the TTL is set to 240 seconds.

Step 9. To specify how often CDP packets are transmitted, enter the following:

SG350X(config)#cdp timer [seconds]

- seconds — Value of the Transmission Timer in seconds. The value should be lesser than the value of the TTL.

Note: This is the rate in seconds at which CDP advertisement updates are sent. The default value is 60 seconds. In this example, the timer is set to 120 seconds.

Step 10. To specify the format of the Device-ID TLV, enter the following:

SG350X(config)#cdp device-id format [mac | serial-number | hostname]

- mac — Specifies that the Device-ID TLV contains the MAC address of the device.

- serial-number — Specifies that Device-ID TLV contains the hardware serial number of the device.

- hostname — Specifies that Device-ID TLV contains the hostname of the device.

Note: In this example, Device-ID TLV should have the MAC address of the device.

Step 11. To specify the CDP source port used for source IP address selection, enter the following:

SG350X(config)#cdp source-interface [interface-id]

- interface-id — Source port used for Source IP address selection. This IP address will be used in the TLV of the frames.

Note: This will specify an interface whose minimal IP address will be advertised in the TLV instead of the minimal IP address of the outgoing interface.

Configure CDP Settings on a Interface

Step 12. In the Global Configuration mode, enter the Interface Configuration context by entering the following:

SG350X(config)#interface [interface-id]

- interface-id — Specifies an Ethernet port ID.

Step 13. To enable CDP on the interface, enter the following:

SG350X(config-if)#cdp enable

Note: CDP is enabled by default.

Step 14. (Optional) To enable validating that the VoIP status of the port received in a CDP packet matches its actual configuration and generation of the SYSLOG VoIP mismatch messages if they do not match, enter the following:

SG350X(config-if)#cdp log mismatch voip

Note: When enabled, a SYSLOG message will be sent when a voice VLAN mismatch is detected. This means that the voice VLAN information in the incoming frame does not match what the local device is advertising. This feature is enabled by default.

Step 15. (Optional) To enable validating that the native VLAN received in a CDP packet matches the actual native VLAN of the port and generation of the SYSLOG VLAN native mismatch messages if they do not match, enter the following:

SG350X(config-if)#cdp log mismatch native

Note: When enabled, a SYSLOG message will be sent when a native VLAN mismatch is detected. This means that the native VLAN information in the incoming frame does not match what the local device is advertising. This feature is enabled by default.

Step 16. (Optional) To enable validating that the duplex status of a port received in a CDP packet matches the ports actual configuration and generation of the SYSLOG duplex mismatch messages if they do not match, enter the following:

SG350X(config-if)#cdp log mismatch duplex

Note: When enabled, a SYSLOG message will be sent when duplex information is mismatched. This means that the duplex information in the incoming frame does not match what the local device is advertising. This feature is enabled by default.

Step 17. Enter the end command to go back to the Privileged EXEC mode:

SG350X(config-if)#end

You should now have successfully configured the CDP settings on your switch through the CLI.

Display or Clear the CDP Settings

Step 1. To display the global CDP information on the switch, enter the following:

SG350X#show cdp

Note: In this example, the general information on the configured CDP settings on the switch is displayed.

Step 2. (Optional) To display information about specific neighbors, enter the following:

SG350X#show cdp entry [* | device-name] [protocol | version]

The options are:

- * — Specifies all neighbors.

- device-name — Specifies the name of the neighbor.

- protocol — Limits the display to information about the protocols enabled on neighbors.

- version — Limits the display to information about the version of software running on the neighbors.

Note: In this example, CDP information of all neighbors are displayed.

Step 3. To display information about ports on which CDP is enabled, enter the following:

SG350X#show cdp interface [interface-id]

- interface-id — Specifies an Ethernet port ID.

Note: In this example, CDP settings on port ge1/0/2 are displayed.

Step 4. To display information about neighbors kept in the main or secondary cache, enter the following:

SG350X#show cdp neighbors [interface-id] [detail | secondary]

- interface-id — Displays the neighbors attached to this port.

- detail — Displays detailed information about a neighbor (or neighbors) from the main cache including network address, enabled protocols, hold time, and software version.

- secondary — Displays information about neighbors from the secondary cache.

Note: In this example, information about neighbors from the secondary cache are shown.

Step 5. (Optional) To display the CDP counters, including the number of packets sent and received and checksum errors, enter the following:

SG350X#show cdp tlv [interface-id]

- interface-id — (Optional) Specifies an Ethernet port ID.

Note: In this example, CDP counters for interface ge1/0/1 are displayed.

Step 6. To display the CDP counters, including the number of packets sent and received and checksum errors, enter the following:

SG350X#show cdp traffic [global | interface-id]

- global — Display only the global counters.

- interface-id — Port for which counters should be displayed.

The counters display the following:

- Total packets output — The number of CDP advertisements sent by the local device. Note that this value is the sum of the CDP Version 1 advertisements output and CDP Version 2 advertisements output fields.

- Input — The number of CDP advertisements received by the local device. Note that this value is the sum of the CDP Version 1 advertisements input and CDP Version 2 advertisements input fields.

- Hdr syntax — The number of CDP advertisements with bad headers, received by the local device.

- Chksum error — The number of times the checksum (verifying) operation failed on incoming CDP advertisements.

- No memory — The number of times the local device did not have enough memory to store the CDP advertisements in the advertisement cache table when the device was attempting to assemble advertisement packets for transmission and parse them when receiving them.

- Invalid — The number of invalid CDP advertisements received.

- CDP version 1 advertisements output — The number of CDP Version 1 advertisements sent by the local device.

- CDP version 1 advertisements Input — The number of CDP Version 1 advertisements received by the local device.

- CDP version 2 advertisements output — The number of CDP Version 2 advertisements sent by the local device.

- CDP version 2 advertisements Input — The number of CDP Version 2 advertisements received by the local device.

Note: In this example, details on global CDP traffic are displayed.

Step 7. (Optional) To reset the CDP traffic counters to 0, enter the following:

SG350X#clear cdp counters [global | interface-id]

- global — Clear only the global counters.

- interface-id — Specifies the interface identifier of the counters that should be cleared.

Note: In this example, CDP traffic for interface ge1/0/2 are reset to zero.

Step 8. (Optional) To delete the CDP Cache tables, enter the following:

SG350X#clear cdp table

Step 9. (Optional) In the Privileged EXEC mode of the switch, save the configured settings to the startup configuration file by entering the following:

SG350X#copy running-config startup-config

Step 10. (Optional) Press Y for Yes or N for No on your keyboard once the Overwrite file [startup-config].... prompt appears.

You should now have displayed or cleared the CDP configuration settings on your switch through the CLI.

View a video related to this article...

Click here to view other Tech Talks from Cisco