Enable CDP on VMware vSS

The Cisco Discovery Protocol (CDP) is used to discover and advertise the identity and capabilities of a network component to other networking components. CDP a proprietary protocol developed by Cisco, so it’s often used on Cisco switches and routers. The Link Layer Discovery Protocol (LLDP) is a vendor-neutral discovery protocol, which is used e.g. by Hewlett-Packard. With CDP or LLDP you can easily get an overview over a network topology. You can quickly check, e.g. what switches are connected to an uplink. Both protocols use Ethernet Multicast to advertise and receive information. CDP usess the address 01:00:0C:CC:CC:CC, LLDP 01:80:C2:00:00:0E.

Wouldn’t it be nice, if you could use CDP or LLDP on a physical switch to discover the pNICs of you ESXi hosts? Would be great, wouldn’t it? ;) Yes, it’s possible! VMware vNetwork Standard Switches (vSS) support CDP, vNetwork Distributed Switches (vDS) support also LLDP. Maybe you noticed this little blue exclamation mark in the vSphere Web Client.

Patrick Terlisten/ vcloudnine.de/ Creative Commons CC0

Patrick Terlisten/ vcloudnine.de/ Creative Commons CC0

Of course you can use the vSphere Client to watch this information. But in this article I will focus on CDP and the vSphere Web Client. By default a vSS only receives CDP information. This is not a problem if you’re in a Cisco enviroment. If you’re using HP Networking components, e.g. HP ProVision based switches, you will not see CDP information received by the vSS. By default HP ProVision based switches use LLDP and they doesn’t send advertise information by CDP. They only listen to CDP traffic. You have to turn the tables around and tell the vSS so advertise information by CDP.

How to enable CDP on vNetwork Standard Switches?

You can use esxcfg-vswitch esxcli or PowerCLI to enable CDP. To be honest: PowerCLI uses the Get-EsxCli to set the necessary parameters. This is an example using the esxcfg-vswitch command:

~ # esxcfg-vswitch -b vSwitch0
listen
~ # esxcfg-vswitch -B both vSwitch0
~ # esxcfg-vswitch -b vSwitch0
both
~ #

The switch -b prints out the current state. This is by default “listen”. -B sets a CDP mode. -B both enables listening and advertising. The vSS will start immediately to advertise itself using CDP. This is the output from a HP 2510-24G switch, before and after enabling CDP on the vSS:

SW# sh cdp neighbors

 CDP neighbors information

  Port Device ID                     | Platform                     Capability
  ---- ----------------------------- + ---------------------------- -----------
  6    18 a9 05 b8 59 69             |
  23   c0 91 34 74 92 00             | ProCurve J9279A Switch 25... S
  24   c0 91 34 74 92 00             | ProCurve J9279A Switch 25... S

SW# sh cdp neighbors

 CDP neighbors information

  Port Device ID                     | Platform                     Capability
  ---- ----------------------------- + ---------------------------- -----------
  1    esx01.domain.tld              | Releasebuild-1623387VMwar... S
  2    esx01.domain.tld              | Releasebuild-1623387VMwar... S
  5    esx01.domain.tld              | Releasebuild-1623387VMwar... S
  6    18 a9 05 b8 59 69             |
  23   c0 91 34 74 92 00             | ProCurve J9279A Switch 25... S
  24   c0 91 34 74 92 00             | ProCurve J9279A Switch 25... S

SW#

If you want to use PowerCLI, you have to use the Get-EsxCli cmdlet.

$esxcli = Get-EsxCli -VMHost <hostname or IP address>
$esxcli.network.vswitch.standard.set("both","9000","vSwitch0")

Please note, that the command expects the MTU as a parameter. If you have changed the MTU don’t copy ’n paste this. It will set the MTU of the vSS to 1500 bytes. If you have to change this for a number of hosts, take a look at a PowerCLI function written by Maish Saidel-Keesing. The third method is using esxcli to set CDP operation mode:

esxcli network vswitch standard set –c both –v vSwitch0

Regardless what method you choose, this will only affect the vSS. If your network equipment doesn’t send CDP information, you will not see any CDP information in the VMware (Web) Client. So if you use HP ProVision based switches, you will only see the CDP information sent by the vSS on the ProVision based switch.