Blue Boxes
Virtualization tips, news and more

VMware ESX Networking | Working with Cisco Discovery Protocol (CDP) Part 1

A network administrator once told me that if your network is based on Cisco devices one thing that you should not forget to work with is CDP (Cisco Discovery Protocol). A few years later I found myself working with a lot of Cisco devices and VMware ESX Servers and discovered that one of the most interesting things is the ability to understand the network topology using Cisco Discovery Protocol o CDP.

By default CDP is configured on VMware ESX Servers just for listen their neighborhoods on the network. To verify this type the following command:

[root@esxserver root]# esxcfg-vswitch -b vSwitch0
listen
[root@esxserver root]#

Where vSwitch0 is the virtual switch that we want to use CDP on.

In order to view the options that we have to work with CDP type the following commnad:

[root@esxserver root]# esxcfg-vswitch
esxcfg-vswitch [options] [vswitch[:ports]]
  -a|—add                          Add a new virtual switch.
  -d|—delete                     Delete the virtual switch.
  -l|—list                            List all the virtual switches.
  -L|--link=pnic                  Set pnic as an uplink for the vswitch.
  -U|--unlink=pnic             Remove pnic from the uplinks for the vswitch.
  -M|--add-pg-uplink         Add an uplink to the list of uplinks for a portgroup
  -N|--del-pg-uplink          Delete an uplink from the list of uplinks for a portgroup
  -p|--pg=portgroup          Specify a portgroup for operation
                                         Use ALL to set VLAN IDs on all portgroups
  -v|--vlan=id                     Set vlan id for portgroup specified by –p
                                         0 would disable the vlan
  -c|—check                       Check to see if a virtual switch exists.
                                         Program outputs a 1 if it exists, 0 otherwise.
  -A|--add-pg=name          Add a new portgroup to the virtual switch.
  -D|--del-pg=name           Delete the portgroup from the virtual switch.
  -C|--check-pg=name       Check to see if a portgroup exists.  Program
                                         outputs a 1 if it exists, 0 otherwise.
  -B|--set-cdp                    Set the CDP status for a given virtual switch.
                                         To set pass one of "down", "listen", "advertise", "both".
  -b|--get-cdp                   Print the current CDP setting for this switch.
  -m|--mtu=MTU                Set MTU for the vswitch. This affects all the nics attached on the vswitch.
  -r|—restore                     Restore all virtual switches from the configuration file
                                         (FOR INTERNAL USE ONLY).
  -h|—help                         Show this message.
[root@esxserver root]#

In order to enable the vSwitch to announce itself with the network and listen to it’s neighrhods we must set CDP on “both” mode. In order to set it that way use the following command:

[root@esxserver root]# esxcfg-vswitch -B both vSwitch0
[root@esxserver root]#

In our example the server the Cisco Discovery Protocol was set on “both” already.

VMware ESX Server - Cisco Discovery Protocol CDP Configuration

Hope this helps.