How to use the CDP feature on VMware vSwitches with HP Procurve physical switches.
In this blog post we looked at the new support for vendor neutral discovery protocol LLDP in vSphere 5. Unfortunately LLDP is only available on the Distributed Virtal Switches and not for ordinary vSwitch.
However, for a long time we had CDP (Cisco Discovery Protocol) in the vSwitches, but as the name implies is a Cisco proprietary method. If running Cisco devices this is no problem, but for example HP Procurve has no full support for CDP. This means that they cannot send any CDP data, but is actually allowed to read CDP sent to them. By enabling CDP in the virtual vSwitches we could help the network administrators a lot and will ease both setup and later troubleshooting.
Enabling CDP is not hard, but must be done from the command line. Access each host through local ESXi Shell or SSH and make a note of the names of all vSwitches by running:
esxcfg-vswitch -l | grep vSwitch
This creates an easy-to-read list of the vSwitches. Now use the -B parameter to turn on CDP in both listen and send mode:
esxcfg-vswitch vSwitch0 -B both
Attach the name of the vSwitch (note that the name is case sensitive). The command returns no feedback if successful, so no news is good news.
You could use lowercase -b to see the actual CDP state of the vSwitch. Default is to only listen, but not send. If having HP switches this default means no information will be sent in any direction, but the -B will enable CDP frames to travel from the virtual switches to the physical network.
This must be done once on all vSwitches on all hosts. Some seconds later the vSwitches will start sending CDP discovery messages to the physical switches and even on systems like HP Procurve without full CDP this information could still be viewed.
The same command could be used to discover both LLDP and CDP neighbors:
show lldp info remote-device
(Could also be abbreviated to “sh lldp i r“)
We can see that the physical switch now have a very good visibility into the virtual environment. Note on the output above that two ESXi hosts are connected to the switch and that the host names and VMNIC number are very clearly displayed together with the local switch ports.
This means that vSwitch CDP is very useful on sites with either Cisco or HP switches and is a good practice to enable on all vSwitches.