VMware CDP returns localhost

In a Cisco network it’s possible to check a connected device using CDP. By default an ESXi server uses the listen setting for CDP. This enables you to see to which switch and port your host is connected in the VI Client.

Because we have a Cisco network we decided to also let the hosts send out it’s own information to the switches. We then used this to generate an automatic drawing of our network.

This is when things got odd: all hosts were returning localhost as the hostname. This made a strange drawing seeing al the “localhosts” as interfaces to the same hosts and drawing direct lines between all our datacenters.

What I first checked:

  • Hostname setting of the hosts
  • (r)DNS records for the hosts
  • Setting of CDP on the hosts (esxcfg-vswitch –b vSwitch0)

When this all didn’t work I came to a very simple solution.

If you you change the default setting of listen to both apparently the vSwitch doesn’t truly reload it’s settings.

You have to first set CDP to down before you set it to both. It’s actually very simple, but maybe it will save you some time.

Please remember that we use ESXi 3.5 and that I don’t know if this is also the case for ESX (non i). Also note that these commands where done at the console. Our ESXi hosts are running “unsupported”. This can also be done with Remote CLI, but we have VIMA which apparently can’t set CDP for hosts below ESX 4 and I was in a hurry (and I’m lazy).

leave your comment