<

Go Premium for a chance to win a PS4. Enter to Win

x

How to enable Link Layer Discovery Protocol (LLDP) in vSwitch

Published on
3,524 Points
524 Views
Last Modified:
Luciano Patrão
My main areas of expertise are VMware, Virtual Backups and Storage design.
I am a vExpert and a Technical Blogger in the same areas.
It Is not possible to enable LLDP in vSwitch(at least is not supported by VMware), so in this article we will enable this, and also go trough how to enabled CDP and how to get this information in vSwitches and also in vDS.
Since most of the times these are 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). For this case was only vSwitch created in the ESXi,  so there was a way to configure this LLDP (we were using Juniper Switches) in the vSwitch using vsish command.
 
So in this article I will try to go trough CDP and also trough LLDP, how to configure and also how check the information in vCenter provided by this feature.
 
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.
 
[root@hostname:~] esxcfg-vswitch -b vSwitch0
listen
 
[root@hostname:~]esxcfg-vswitch -B both vSwitch0

Open in new window



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 vSwtiches(one a the time)
We will use vSwitch0 to enable LLDP. Then we will 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.
 

[root@hostname:~] vsish
/> cd /net/portsets/vSwitch0
/net/portsets/vSwitch0/>
/net/portsets/vSwitch0/> ls
ports/
overlays/
uplinks/
vlans/
isResvSupported
netEventChain
type
enableDetailedStats
mtu
unlink
link
destroy
properties
stats
niocPendingVms/
niocNoResvPorts/
niocPendingVnics/
niocPendingPorts/
/net/portsets/vSwitch0/> cd /net/portsets/vSwitch0/ports/
/net/portsets/vSwitch0/ports/> ls
33554433/
33554434/
33554435/
33554436/
33554437/
33554438/
/net/portsets/vSwitch0/ports/>

Open in new window



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 ports we will use get status for each port.
Just run the command to each port to identify witch ones are from the vmnics.

 
 /net/portsets/vSwitch0/ports/> get 33554433/status

Open in new window




Since this port doesn’t mach a vmnic, lets check the next one.






Screen-Shot-09-23-16-at-04.02-AM.PNG
/net/portsets/vSwitch0/ports/> get 33554434/status

Open in new window








Screen-Shot-09-23-16-at-04.03-AM.PNGAs we can see in the highlight, this port belongs to vmnic0. So do the same for all ports and then we will enable the LLDP in the right ports.

In this case these are the ports that were identify.
33554433 — management
33554434 — vmnic0
33554435 — shadow vmnic0
33554436 — vmnic9
33554437 — shadow vmnic9
33554438 — vmk0 (if you have any vmkernel in the vSwitch all will be displayed here as 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 – will provide the state of the LLDP (0 is disable, 1 is enable)
set enable 0/1 – is to enable or disable the LLDP
With this commands you can enable LLDP in your ports.

/net/portsets/vSwitch0/ports/> cd 33554434/lldp/
/net/portsets/vSwitch0/ports/33554434/lldp/> typels enable
VSI_BOOL
/net/portsets/vSwitch0/ports/33554434/lldp/> get enable
0
/net/portsets/vSwitch0/ports/33554434/lldp/> set enable 1
/net/portsets/vSwitch0/ports/33554434/lldp/> get enable
1
/net/portsets/vSwitch0/ports/33554434/lldp/>

Open in new window


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


VSISH_VSWITCH_PATH=/net/portsets
for vSwitch in $(vsish -e ls ${VSISH_VSWITCH_PATH});
do
   VSWITCH=$(echo ${vSwitch} | sed 's/\///g')
   for port in $(vsish -e ls ${VSISH_VSWITCH_PATH}/${vSwitch}ports);
   do
      PORT=$(echo ${port} | sed 's/\///g')
      PORTINFO=$(vsish -e get ${VSISH_VSWITCH_PATH}/${vSwitch}ports/${port}status | sed 's/^[ \t]*//;s/[ \t]*$//');
      CLIENT=$(echo ${PORTINFO} | sed 's/ /\n/g' | grep "clientName:" | awk -F ":" '{print $2}')
      MACADDRESS=$(echo ${PORTINFO} | sed 's/ /\n/g' | grep "unicastAddr:" | uniq | sed 's/unicastAddr://;s/\(.*\)./\1/')
      vmnics=$(echo -e "${PORT}\t${CLIENT}" | grep vmnic | awk '{ print $1 }')
      for i in $vmnics;
      do
         vsish -e typels /net/portsets/vSwitch0/ports/$i/lldp/enable
         vsish -e set /net/portsets/vSwitch0/ports/$i/lldp/enable 1
      done
   done
done

Open in new window

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).

lldp01
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.
lldp03Check in the next image where you can list the CDP / LLDP from the vSwitch using vSphere Web client.
lldp02Hope this information was useful.

This is the part of my "TIP Articles". So, please vote "Helpful" on this Article. And I encourage your comments and feedback.

Thank You

Luciano Patrão
0
Comment
1 Comment
 
LVL 24

Author Comment

by:Luciano Patrão
Hi,

I have more articles waiting to be approved.

I will change the images, but this "new" tool to write articles is not very good.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Join & Write a Comment

Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…
In this video tutorial I show you the main steps to install and configure  a VMware ESXi6.0 server. The video has my comments as text on the screen and you can pause anytime when needed. Hope this will be helpful. Verify that your hardware and BIO…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month