Configuring CDP

Configuring CDP

This chapter contains the following sections:

Information About CDP

The Cisco Discovery Protocol (CDP), which runs over the data link layer, is used to advertise information to all attached Cisco devices and to discover and view information about attached Cisco devices. CDP runs on all Cisco-manufactured equipment.

Each device that you configure for CDP sends periodic advertisements to a multicast address. Each device advertises at least one address at which it can receive SNMP messages. The advertisements also contain hold-time information, which indicates the length of time that a receiving device should hold CDP information before discarding it. You can configure the advertisement or refresh timer and the hold timer.

CDP Version 2 (CDPv2) allows you to track instances where the native VLAN ID or port duplex states do not match between connecting devices.

CDP advertises the following type-length-value fields (TLVs):

  • Device ID
  • Address
  • Port ID
  • Capabilities
  • Version
  • Platform
  • Native VLAN
  • Full/half duplex
  • MTU
  • Sysname
  • SysObjectID
  • Management address
  • Physical location

All CDP packets include a VLAN ID. The CDP packet is untagged, so it goes over the native/access VLAN, which is then also added to the packet.

High Availability

Stateless restarts are supported for CDP. After a reboot or a supervisor switchover, the running configuration is applied.

Guidelines and Limitations

  • CDP gathers protocol addresses of neighboring devices and discovers the platform of those devices. CDP runs over the data link layer only. With CDP, two systems that support different Layer 3 protocols can learn about each other.
  • CDP can discover up to 256 neighbors per port if the port is connected to a hub with 256 connections.
  • CDP must be enabled globally before you can configure CDP on an interface. CDP is enabled globally by default but can be disabled.
  • You can configure CDP on physical interfaces and port channels only.

Default Settings

Parameters

Default

CDP

Enabled globally and on all interfaces

CDP version

Version 2

CDP device ID

System name

CDP timer

60 seconds

CDP hold timer

180 seconds

Configuring CDP

This section includes the following topics:

  • CDP Global Configuration
  • Enabling CDP on an Interface
  • Disabling CDP on an Interface

Enabling or Disabling CDP Globally

Be sure you understand that when you globally disable the CDP feature, all CDP configurations are removed.

Before You Begin

Before beginning this procedure, you must be logged in to the CLI in EXEC mode.

Procedure
     Command or ActionPurpose
    Step 1switch# config t  

    Places you in global configuration mode.

     
    Step 2switch(config)# [no] cdp enable 

    Enables or disables the CDP feature globally.

     
    switch# config t
    switch(config)# no cdp enable

    Enabling or Disabling CDP on an Interface

    You can enable or disable CDP on an interface.

    Note


    Although CDP is enabled by default on all interfaces, should it become disabled, you can use this procedure to enable it again.


    Procedure
       Command or ActionPurpose
      Step 1switch# configure terminal 

      Enters global configuration mode.

       
      Step 2switch(config)# interface interface-type number  

      Places you in interface configuration mode for the specific interface.

       
      Step 3switch(config-if)# [no] cdp enable 

      Disables or enables CDP on this interface.

       
      Step 4switch(config-if)# show cdp interface interface-type number  (Optional)

      Displays CDP information for the specified interface.

       
      Step 5switch(config-if)# copy running-config startup-config  (Optional)

      Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

       
      switch# config terminal
      switch(config)# interface ethernet 3/1
      switch(config-if)# no cdp enable 
      switch(config-if)# show cdp interface mgmt0
      mgmt0 is up
          CDP disabled on interface
          Sending CDP packets every 60 seconds
          Holdtime is 180 seconds
      switch(config)# copy running-config startup-config

      Configuring CDP Options

      You can configure the following for CDP:

      • The device ID format to use

        Note


        Only the system-name device ID format is supported


      • The maximum hold time for neighbor information
      • The refresh time for sending advertisements

      Note


      You can view output from the upstream Catalyst 6500 Series switch by using the show cdp neighbor command.


      Before You Begin

      Before beginning this procedure, be sure you know the following information:

      • How long you want CDP to retain neighbor information if you are setting the holdtime.
      • How often you want CDP to advertise if you are setting the CDP timer.
      Procedure
         Command or ActionPurpose
        Step 1switch# configure terminal 

        Enters global configuration mode.

         
        Step 2switch(config)# cdp format device-id system-name  (Optional)

        Specifies that CDP uses the system name for the device ID format.

         
        Step 3switch(config)# show cdp neighbors 

        Displays the upstream device from your device.

         
        Step 4switch(config)# cdp holdtime seconds  (Optional)
        Sets the maximum amount of time that CDP holds onto neighbor information before discarding it.
        • The range for the seconds argument is from 10 to 255 seconds.
        • The default is 180 seconds.
         
        Step 5switch(config)# cdp timer seconds 
        Sets the refresh time for CDP to send advertisements to neighbors.
        • The range for the seconds argument is from 5 to 254 seconds.
         
        Step 6switch(config)# show cdp global   (Optional)

        Displays the CDP version that is being advertised or sent to other devices.

         
        Step 7switch(config)# copy running-config startup-config  (Optional)

        Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

         
        switch# config terminal
        switch(config)# cdp format device-id system-name 
        switch(config)# show cdp neighbors 
        Capability Codes: R - Router, T - Trans-Bridge, B - Source-Route-Bridge
                          S - Switch, H - Host, I - IGMP, r - Repeater,
                          V - VoIP-Phone, D - Remotely-Managed-Device,
                          s - Supports-STP-Dispute
        
        Device ID              Local Intrfce   Hldtme  Capability  Platform      Port ID
        
        swordfish-6k-2         Eth2/2          169     R S I    WS-C6503-E    Gig1/14 
        swordfish-6k-2         Eth2/3          139     R S I    WS-C6503-E    Gig1/15 
        swordfish-6k-2         Eth2/4          135     R S I    WS-C6503-E    Gig1/16 
        swordfish-6k-2         Eth2/5          177     R S I    WS-C6503-E    Gig1/17 
        swordfish-6k-2         Eth2/6          141     R S I    WS-C6503-E    Gig1/18 
        switch(config)# cdp holdtime 10
        switch(config)# cdp timer 5
        switch(config)# show cdp global 
        Global CDP information:
            CDP enabled globally
            Sending CDP packets every 5 seconds
            Sending a holdtime value of 10 seconds
            Sending CDPv2 advertisements is disabled
            Sending DeviceID TLV in Mac Address Format
        switch(config-if)# copy running-config startup-config

        Advertising a CDP Version

        Before beginning this procedure, be sure you have know the following information:

        • The version of CDP currently supported on the device.
        • Only one version of CDP (version 1 or version 2) is advertised at a time for all uplinks and port channels on the switch.
        Before You Begin

        Before beginning this procedure, you must be logged in to the CLI in EXEC mode.

        Procedure
           Command or ActionPurpose
          Step 1switch# config t  

          Places you in global configuration mode.

           
          Step 2switch(config)# cdp advertise {v1 | v2} 
          Assigns the CDP version to advertise:
          • CDP Version 1
          • CDP Version 2
           
          Step 3switch(config)# show cdp global   (Optional)

          Displays the CDP version that is being advertised or sent to other devices.

           
          Step 4switch(config)# copy running-config startup-config  (Optional)

          Copies the running configuration to the startup configuration.

           
          switch# config t
          switch(config)# cdp advertise v1
          switch(config)# show cdp global 
          Global CDP information:
              CDP enabled globally
              Sending CDP packets every 60 seconds
              Sending a holdtime value of 180 seconds
              Sending CDPv2 advertisements is disabled
              Sending DeviceID TLV in Default Format
          switch(config)# copy running-config startup-config

          Verifying the CDP Configuration

          Use one of the following commands to verify the configuration:

          Command

          Purpose

          show cdp all

          Displays all interfaces that have CDP enabled.

          show cdp entry {all | name entry-name}

          Displays the CDP database entries.

          show cdp global

          Displays the CDP global parameters.

          show cdp interface interface-type slot/port

          Displays the CDP interface status.

          show cdp neighbors {detail | interface interface-type slot/port}

          Displays the CDP neighbor status.

          Monitoring CDP

          Monitoring CDP Statistics

          Command

          Purpose

          show cdp traffic interface interface-type slot/port

          Displays the CDP traffic statistics on an interface.

          Clearing CDP Statistics

          Use one of the following commands to clear CDP statistics:

          Command

          Purpose

          clear cdp counters

          Clears CDP statistics on all interfaces.

          clear cdp counters interface number

          Clears CDP statistics on the specified interface.

          clear cdp table

          Clears the CDP cache for one or all interfaces.

          Configuration Example for CDP

          This example shows how to enable the CDP feature and configures the refresh and hold timers:

          switch# config t
          switch(config)# cdp enable
          switch(config)# cdp timer 50
          switch(config)# cdp holdtime 100

          Feature History for CDP

          Feature

          Releases

          Feature Information

          CDP

          Release 5.2(1)SK1(2.1)

          This feature was introduced.