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:
If you prefer to configure CDP settings using the Graphical User Interface (GUI), click here.
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#configureStep 3. To globally enable CDP on the switch, enter the following:
SG350X(config)#cdp runNote: 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:
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 enableNote: 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 validationNote: 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-v2Note: 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]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]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]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]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.
Step 12. In the Global Configuration mode, enter the Interface Configuration context by entering the following:
SG350X(config)#interface [interface-id]Step 13. To enable CDP on the interface, enter the following:
SG350X(config-if)#cdp enableNote: 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 voipNote: 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 nativeNote: 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 duplexNote: 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)#endYou should now have successfully configured the CDP settings on your switch through the CLI.
Step 1. To display the global CDP information on the switch, enter the following:
SG350X#show cdpNote: 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:
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]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]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]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]The counters display the following:
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]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 tableStep 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-configStep 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.
Revision | Publish Date | Comments |
---|---|---|
1.0 |
12-Dec-2018 |
Initial Release |