Cisco Discovery Protocol (CDP) network information
search cancel

Cisco Discovery Protocol (CDP) network information

book

Article ID: 324750

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere ESXi

Issue/Introduction

This article provides steps to view Cisco Discovery Protocol (CDP) information.

Symptoms:



Environment

VMware ESXi 3.5.x Embedded
VMware ESXi 4.0.x Installable
VMware vCenter Server 5.1.x
VMware vCenter Server 4.1.x
VMware ESXi 4.1.x Installable
VMware ESX 4.0.x
VMware VirtualCenter 2.5.x
VMware ESX Server 3.5.x
VMware vSphere ESXi 5.5
VMware vCenter Server 5.0.x
VMware ESXi 4.0.x Embedded
VMware vCenter Server 5.5.x
VMware vSphere ESXi 5.0
VMware vCenter Server 4.0.x
VMware ESX 4.1.x
VMware ESXi 4.1.x Embedded
VMware ESXi 3.5.x Installable
VMware vSphere ESXi 5.1

Resolution

CDP is used to share information about other directly-connected Cisco networking equipment, such as upstream physical switches. CDP allows ESX and ESXi administrators to determine which Cisco switch port is connected to a given vSwitch. When CDP is enabled for a particular vSwitch, properties of the Cisco switch, such as device ID, software version, and timeout, may be viewed from the vSphere Client. This information is useful when troubleshooting network connectivity issues related to VLAN tagging methods on virtual and physical port settings.

Note: For CDP information to be available, ESX hosts must be configured to listen for CDP information and connected devices must be advertising CDP information. If CDP information is not available, confirm that CDP is enabled on the ESX virtual switch and physical switch. For more information, see Configuring the Cisco Discovery Protocol (CDP) with ESX (1003885).

CDP information in the vSphere/VI Client


To view CDP information using the vSphere/VI Client:

  1. Connect to the vCenter Server/Virtual Center or ESX host using the vSphere/VI Client.
  2. Select the ESX host in the Inventory.
  3. Click the Configuration tab.
  4. Click Networking.
  5. Click the Info icon to the right of the vSwitch, under Properties. For example:


  6. A tool tip opens with the Cisco Discovery Protocol information for the selected physical network interface. For example:



CDP information via PowerCLI


To display CDP information using PowerCLI:

  1. Using PowerCLI, connect to the ESX host or vCenter Server:

    # Connect-VIServer esx-or-vc-hostname

  2. Run this script in PowerCLI:

    Get-VMHost | Where-Object {$_.ConnectionState -eq "Connected"} |
    %{Get-View $_.ID} |
    %{$esxname = $_.Name; Get-View $_.ConfigManager.NetworkSystem} |
    %{ foreach($physnic in $_.NetworkInfo.Pnic){
    $pnicInfo = $_.QueryNetworkHint($physnic.Device)
    foreach($hint in $pnicInfo){
    Write-Host $esxname $physnic.Device
    if( $hint.ConnectedSwitchPort ) {
    $hint.ConnectedSwitchPort
    }
    else {
    Write-Host "No CDP information available."; Write-Host
    }
    }
    }
    }


    The CDP information for each physical network interface on each connected ESX host is displayed.

    For example:

    esxhostname vmnic0
    CdpVersion : 2
    Timeout : 0
    Ttl : 177
    Samples : 54732
    DevId : example-lab-b2-c02
    Address : 10.11.12.254
    PortId : GigabitEthernet1/0/7 <<< Switch Port ID >>>
    DeviceCapability : VMware.Vim.PhysicalNicCdpDeviceCapability
    SoftwareVersion : Cisco IOS Software, C3750 Softw
    HardwarePlatform : cisco WS-C3750G-24TS-1U
    IpPrefix : 0.0.0.0
    IpPrefixLen : 0
    Vlan : 1 <<< VLan ID >>>
    FullDuplex : True
    Mtu : 0
    SystemName :
    SystemOID :
    MgmtAddr : 10.11.12.254
    Location :


  3. To get more information about the uplink Cisco switch and related configured physical switch ports with CDP, run this script in PowerCLI:

    param($VMHost)
    $vmh = Get-VMHost $VMHost
    If ($vmh.State -ne "Connected") {
    Write-Output "Host $($vmh) state is not connected, skipping."
    }
    Else {
    Get-View $vmh.ID | `
    % { $esxname = $_.Name; Get-View $_.ConfigManager.NetworkSystem} | `
    % { foreach ($physnic in $_.NetworkInfo.Pnic) {
    $pnicInfo = $_.QueryNetworkHint($physnic.Device)
    foreach( $hint in $pnicInfo ){
    # Write-Host $esxname $physnic.Device
    if ( $hint.ConnectedSwitchPort ) {
    $hint.ConnectedSwitchPort | select @{n="VMHost";e={$esxname}},@{n="VMNic";e={$physnic.Device}},DevId,Address,PortId,HardwarePlatform
    }
    else {
    Write-Host "No CDP information available."
    }
    }
    }
    }
    }

    For example, if this script is saved as Get-mVMHostCDPInfo.ps1 :

    # Get-mVMHostCDPInfo.ps1 -VMHost esxhostname | ft -a

    VMHost VMNic DevId Address PortId HardwarePlatform
    ------ ----- ----- ------- ------ ----------------
    esxhostname vmnic0 esx1.mon.com 1.1.1.1 GigabitEthernet1/0/9 cisco WS-C3750G-24TS-1U
    esxhostname vmnic1 esx1.mon.com 1.1.1.1 GigabitEthernet2/0/21 cisco WS-C3750G-24TS-1U
    esxhostname vmnic2 esx1.mon.com 1.1.1.1 GigabitEthernet1/0/10 cisco WS-C3750G-24TS-1U
    esxhostname vmnic3 esx1.mon.com 1.1.1.1 GigabitEthernet2/0/10 cisco WS-C3750G-24TS-1U
    esxhostname vmnic4 esx1.mon.com 1.1.1.1 GigabitEthernet1/0/11 cisco WS-C3750G-24TS-1U
    esxhostname vmnic5 esx1.mon.com 1.1.1.1 GigabitEthernet2/0/11 cisco WS-C3750G-24TS-1U
    esxhostname vmnic6 esx2.mon.com 1.1.1.2 GigabitEthernet1/0/6 cisco WS-C3750G-24TS-1U
    esxhostname vmnic7 esx2.mon.com 1.1.1.2 GigabitEthernet1/0/8 cisco WS-C3750G-24TS-1U

CDP information via the ESX/ESXi command line


To view CDP information using the ESX/ESXi command line:

  1. Log into ESX/ESXi via SSH or the console as root.
  2. Run this command to view the CDP information:

    For ESX 4.x:

    # vmware-vim-cmd hostsvc/net/query_networkhint

    For ESXi 4.x and 5.x:

    # vim-cmd hostsvc/net/query_networkhint

    For ESXi 4.x and 5.x if you want to specify only one physical NIC to query run:

    # vim-cmd hostsvc/net/query_networkhint --pnic-name=vmnic[xx]

    Note: Log into the ESXi host at the console. For more information, see Tech Support Mode for Emergency Support (1003677).

    The CDP information for each physical network interface on each connected ESX host is displayed.

    For example:

    (vim.host.PhysicalNic.NetworkHint) [
    (vim.host.PhysicalNic.NetworkHint) {
    dynamicType = ,
    device = "vmnic3",
    subnet = (vim.host.PhysicalNic.NetworkHint.IpNetwork) [
    (vim.host.PhysicalNic.NetworkHint.IpNetwork) {
    dynamicType = ,
    vlanId = 0,
    ipSubnet = "10.21.4.1-10.21.7.254",
    }
    ],
    connectedSwitchPort = (vim.host.PhysicalNic.CdpInfo) null,
    },
    (vim.host.PhysicalNic.NetworkHint) {
    dynamicType = ,
    device = "vmnic1",
    subnet = (vim.host.PhysicalNic.NetworkHint.IpNetwork) [
    (vim.host.PhysicalNic.NetworkHint.IpNetwork) {
    dynamicType = ,
    vlanId = 0,
    ipSubnet = "10.21.3.1-10.21.3.15",
    }
    ],
    connectedSwitchPort = (vim.host.PhysicalNic.CdpInfo) {
    dynamicType = ,
    cdpVersion = 0,
    timeout = 0,
    ttl = 169,
    samples = 2982,
    devId = "PA-3210-2-R15-SW1",
    address = "10.21.10.115",
    portId = "GigabitEthernet1/0/7", <<< Switch Port ID >>>
    deviceCapability = (vim.host.PhysicalNic.CdpDeviceCapability) {
    dynamicType = ,
    router = false,
    transparentBridge = false,
    sourceRouteBridge = false,
    networkSwitch = true,
    host = false,
    igmpEnabled = true,
    repeater = false,
    },
    softwareVersion = "Cisco IOS Software, C3750 Softw",
    hardwarePlatform = "cisco WS-C3750G-48TS",
    ipPrefix = "0.0.0.0",
    ipPrefixLen = 0,
    vlan = 3, <<< VLan ID >>>
    fullDuplex = true,
    mtu = 0,
    systemName = "",
    systemOID = "",
    mgmtAddr = "10.21.10.115",
    location = "",
    },
    },
    ]


  3. We can also find the same CDP information by running this command:

    # esxcfg-info | less

    Search for the specific vmnic# (in this example vmnic0 ) to find the CDP information.

    Example output:

    |----Name........................................vmnic0
    |----PCI Bus.....................................3
    |----PCI Slot....................................0
    |----PCI function................................0
    |----MAC Address.................................xx:xx:xx:xx:xx:xx
    |----Virtual MAC Address.........................xx:xx:xx:xx:xx:xy
    |----Driver......................................bnx2
    |----Network Hint................................0 10.112.100.0/255.255.252.0
    |----MTU.........................................1500
    |----Configured Speed............................1000
    |----Actual Speed................................1000
    |----Configured Duplex...........................1
    |----Actual Duplex...............................1
    |----Link Up.....................................true
    |----enabled.....................................true
    |----Wake on LAN supported ......................true
    |----Wake on LAN enabled ........................true
    |----Resource scheduler allowed ................true
    |----Resource scheduler supported ...............true
    |----CDP Network.................................true
    \==+CDP Summary :
    |----Cdp Version.............................2
    |----Timeout.................................0
    |----Time-to-live............................177
    |----Samples.................................20131
    |----Device Id...............................c2960G-lab-c18
    |----Ip Address..............................10.112.106.86
    |----Ip Prefix...............................0.0.0.0/0
    |----Port Id.................................GigabitEthernet0/35
    |----Capabilities............................40
    |----Version.................................Cisco IOS Software, C2960 Software
    |----Platform................................cisco WS-C2960G-48TC-L
    |----Vlan....................................1032
    |----Duplex..................................true
    |----MTU.....................................0
    |----System Name.............................
    |----System OID..............................
    |----Mgmt Ip Address.........................10.112.106.86

To set up the CDP information using the PowerCLI

$esxcli = Get-EsxCli -VMHost $myhost
$esxcli.network.vswitch.standard.set("both","1500","vSwitch0")

To set up the CDP information on ESXi 5.x using the esxcli command

# esxcli network vswitch standard set –c both –v vSwitch#

Note: Replace # with the vSwitch number.


Additional Information

For more information on the VMware vSphere PowerCLI, see the vSphere PowerCLI community page.

To establish compatible virtual switch configuration, see VLAN configuration on virtual switches, physical switches, and virtual machines (1003806).VLAN configuration on virtual switches, physical switches, and virtual machines
Configuring the Cisco Discovery Protocol (CDP) with ESX/ESXi
Cisco 发现协议 (CDP) 网络信息
シスコ検出プロトコル(CDP)ネットワーク情報