Enable Link Layer Discovery Protocol (LLDP) in vSwitch

//Enable Link Layer Discovery Protocol (LLDP) in vSwitch

Enable Link Layer Discovery Protocol (LLDP) in vSwitch

In this article, we go through CDP and also trough LLDP, how to Enable Link Layer Discovery Protocol (LLDP) in vSwitch, but also for vDS and how to check the information in vCenter provided by this feature.

This week we install new ESXi hosts from a remote location. Since we did not have access physically to the Switches/ESXi hosts and we need to double check if the cabling was correct, and also witch interface was connected to which switch port.

When you have your vCenter and all VMware Infrastructure installed, this is easy to enable and discover. By using CDP (for CISCO) or Link Layer Discovery Protocol (LLDP for HP, Juniper or others brands) Network teams can quickly get this information, even we can check this in the vCenter (see images below).

Since this was a new installation(new Switches, ESXi hosts, etc.), there was no vCenter and also no Storage Network (we still need to check where and witch cables are connected). Since there was only one vSwitch created in the ESXi,  so I remember there was a way to configure this LLDP (we were using Juniper Switches) in the vSwitch using the vsish command.

Different ways to grab Physical Switches vs Virtual Switches information :

Listen mode – The ESXi/ESX host detects and displays information about the associated Cisco switch port, but information about the vSwitch is not available to the Cisco, Switch administrator.
Advertise mode – The ESXi/ESX host makes information about the vSwitch available to the Cisco switch administrator but does not detect and displays information about the Cisco switch.
Both mode – The ESXi/ESX host detects and displays information about the associated Cisco switch and makes information about the vSwitch available to the Cisco, switch administrator.

Note: Depending on your Network / Virtual environment you can choose any of this options. In our implementations, most are set with Both, but some we use Listen. So check with your Network Teams what is the best option for them (or for Virtual Administrators).

How to configure CDP in Standard Switch (vSS):

For vSS we need to this by ESXi shell command.

First check what type of mode is set (listen is by default), then enable mode (add your mode option).

To enable LLDP in a vSwith is a more complex.

Note: VMware doesn’t support LLDP in vSwitch, so please be careful using the next steps in Productions environments.

To enable this, we need to connect/read directly into the vSwitch with the command vsish.

Note: If you have more than one vSwitch already configured in your ESXi and want to enable LLDP in all vSwitch, you need to do the steps to all vSwitches(one a the time)

We use vSwitch0 to enable LLDP. Then we go to the folder for ports in this vSwitch0 and list all the ports that are available.

Again, connect to your host in the ESXi Shell.

So in this vSwitch0, we have all these ports

33554433/
33554434/
33554435/
33554436/
33554437/
33554438/

Then we need to check witch port belong to witch vmnics (our ESXi Network Interfaces). To get the information from the vSwitch ports, we use get status for each port.

Just run the command to each port to identify which ones are from the vmnics.

Enable Link Layer Discovery Protocol (LLDP) in vSwitch

Since this port doesn’t match a vmnic, let’s check the next one.

Enable Link Layer Discovery Protocol (LLDP) in vSwitch

As we can see in the highlight, this port belongs to vmnic0. So do the same for all ports and then we enable the LLDP in the right ports.

In this case, these are the ports that were identified.

33554433 — management
33554434 — vmnic0
33554435 — shadow vmnic0
33554436 — vmnic9
33554437 — shadow vmnic9
33554438 — vmk0 (if you have any vmkernel in the vSwitch all are displayed here as a port)

So we need to enabled LLDP in port 33554434 and port 33554436. Because those are the physical ones, the rest is just virtual.

Enter the port folder and in the LLDP folder to enable LLDP.

Commands:

get enable – Provides the state of the LLDP (0 is disabled, 1 is enabled)
set enable 0/1 – is to enable or disable the LLDP

With this commands, you can enable LLDP in your ports.

I found a shell script in the https://gist.github.com/  that do the same trick for all vmnics in the vSwitch. Thanks to AnthonyWC for this script.

There are also some other scripts examples HERE. Note: Did not test this scripts, so tested first in a test environment, before you used in any production environment.

In vCenter:

After your vSwitches have all vmnics configured with LLDP, you can now check with Network Teams(or you own teams) the ports/interfaces connections.

Check in the next image where you can list the CDP / LLDP from the vSwitch using vSphere client (next section we can check how to see this trough vSphere Web Client).

Enable Link Layer Discovery Protocol (LLDP) in vSwitch

How to configure CDP/LLDP in vNetworking Distributed Switch (vDS):

Configuring CDP or LLDP in a vDS is much easier than in a vSS. Since we need vCenter o do this (vDS only works with vCenter ).

  • Using vSphere Client:
  1. Connect to vCenter Server using the vSphere Client.
  2. In the vCenter Server home page, click Networking.
  3. Right-click the vDS and click Edit Settings.
  4. Select Advanced under Properties.
  5. Using the checkbox and the dropdown, change the CDP settings.
  • Using vSphere Web Client:
  1. Connect to vCenter Server using the vSphere Web Client.
  2. In the vCenter Server home page, click Networking.
  3. Right-click the vDS and click Edit Settings.
  4. Select Advanced under Properties.
  5. Using the checkbox and the dropdown, change the CDP / LLDP settings.

Enable Link Layer Discovery Protocol (LLDP) in vSwitch

Check in the next image where you can list the CDP / LLDP from the vSwitch using vSphere Web client.

Enable Link Layer Discovery Protocol (LLDP) in vSwitch

The above tasks can be done in vSphere 5.x/6.7. Tasks and options are the same for every version.

Hope this information was useful.

Note: Share this article, if you think it is worth sharing.

©2017 ProVirtualzone. All Rights Reserved
By | 2018-11-27T18:56:23+01:00 September 23rd, 2016|Virtualization|11 Comments

About the Author:

I am over 20 years’ experience in the IT industry. Working with Virtualization for more than 10 years (mainly VMware). I am an MCP, VCP6.5-DCV, VMware vSAN Specialist, Veeam Vanguard 2018/2019, vExpert vSAN 2018/2019 and vExpert for the last 4 years. Specialties are Virtualization, Storage, and Virtual Backups. I am working for Elits a Swedish consulting company and allocated to a Swedish multinational networking and telecommunications company as a Teach Lead and acting as a Senior ICT Infrastructure Engineer. I am a blogger and owner of the blog ProVirtualzone.com

11 Comments

  1. Vaibhav Tiwari 25/09/2016 at 11:07 - Reply

    thanks for the article

  2. Toni Dantzer 24/01/2017 at 14:49 - Reply

    Nice article, thanks. I encountered 2 problems on a standard vswitch configured as above. First i ran into the problem that i do not get any lldp information in the vSphere client. In my vSphere client i only see some information of the host itself.
    The second problem is that the settings for the vswich ports are gone after a machine reboot an need reenabled after the reboot.
    I am running my environment in 5.5U3.
    Any suggestions?

    • Luciano Patrao 25/01/2017 at 01:46 - Reply

      Hi,

      First, I do not understand when you say information of the host itself. This is only for interfaces(vmnics) in you Virtual Standard Switch. No information about the host will be display here. Check screenshots in the article.
      Second, this is only for LLDP it always depends on the Physical Switch that you have.
      When you do in vsish “get portnumber status” one line you should see something like “flags:port flags: 0x1010c043 -> IN_USE ENABLED UPLINK DISPATCH_STATS_IN DISPATCH_STATS_OUT DISPATCH_STATS CONNECTED LLDP_ENABLED TUNNEL_ENDPOINT”
      That means the LLDP is enabled.

      Regarding host loses changes in the vsish, need to check that. I only use this changes in a initial stage, after ESXi host is configured, I do not need anymore. But will try to check this and reply my findings.

      • Toni Dantzer 25/01/2017 at 10:14 - Reply

        Hi Luciano, thanks for your reply. I will send you an e-mail later today providing some more detail.

  3. Jorge 28/02/2017 at 12:29 - Reply

    Hi All!, and congratulations about the article

    I have the same 2 issues that Toni reports:

    – No LLDP info showed in vSphere console. Just “LLDP not available in this NIC”. But in Switch side LLDP info is correct!!

    – and, after reboot… LLDP activation is missed… and need to be activated again with “set enable 1”

    Running 6.02 Update2, and vSwtich configured in “Both mode” (Listen and advertisement)

    Any idea to solve the issue?
    Thanks in advance!

    • Luciano Patrao 28/02/2017 at 17:03 - Reply

      Hi Jorge,

      Thank you for your reply.
      Have already notice that issue. I am working on solution so that is always persistence after a reboot.

      Will update the post when I found the solution.

      Thank You

      Luciano Patrao

  4. orb 26/09/2017 at 15:25 - Reply

    Hi,

    first, it is not a powershell script, but a standard .sh script. to add persistence after the reboot you need to copy the code in /etc/rc.local.d/local.sh (https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2043564)

    The script has also 2 fixed value and set lldp only in vmnic located in vSwitch0, a quick update can fix that. You have to replace the 2 following lines

    “vsish -e typels /net/portsets/vSwitch0/ports/$i/lldp/enable”
    “vsish -e set /net/portsets/vSwitch0/ports/$i/lldp/enable 1”

    with

    vsish -e typels /net/portsets/${vSwitch}ports/$i/lldp/enable
    vsish -e set /net/portsets/${vSwitch}ports/$i/lldp/enable 1

    if you updated your vswitch, just ssh your esx and run again ./etc/rc.local.d/local.sh

    Enjoy
    Oli

    • Luciano Patrao 26/09/2017 at 21:13 - Reply

      Hi Oliver,

      Thanks for your comment.

      Yes you are correct, is a shell script. I did notice before, was supposed to change it and then I forgot 🙂

      Thanks for the update in the script for all vSwitchs. Will test and if it works will update the article.

      Regarding adding this to the local.sh. I only use this for troubleshooting and do not want this to be persistence and since I am not very fan to do changes in local.sh in production.
      But last time I did some tests in this lldp changes, I was able to change in the way that was persistence after a reboot without the need to run the script every time I need to reboot. When I have time, will test this again, and if this is really the solution, I will update the article with that solution.

      Again, thank your for comment and sharing.

      Luciano Patrao

  5. orb 27/09/2017 at 15:03 - Reply

    Hi Luciano,

    You are welcome.

    I would love to hear about that ! So far, I always followed VMWare KB to make the change somehow persistent after the reboot.
    /sbin/auto-backup.sh doesn’t do the trick.

    Oli

    • Luciano Patrao 01/10/2017 at 16:30 - Reply

      Hi Oliver,

      Unfortunately I was not able to put the changes persistence. I though I could make some changes at vSwitch level that this could be persistence, but I was not able to do that.

      But I am pretty sure that should be a way to do that. Just need to find it 🙂

      Thank again for your comments and help.

      Luciano Patrao

Leave a Reply

%d bloggers like this: