Discovering ESXi Host Neighbors Using nsxcli, vim-cmd or GUI

This tutorial will show you how to Determine ESXi Host Neighbor CDP LLDP Details using CLI and GUI.

In any data center, understanding the network topology is important for troubleshooting, management, and configuration. Sometimes, as a server administrator, you may not have access to physical switches and other network devices. In such cases, it is crucial to identify the connected interfaces so that when there is an issue with a server’s physical interface, it can be accurately identified as a problem with the SFP module, fiber optic cable, network card, or the TOR switch interface.

To ensure synchronization between the network administrator and the server administrator and to avoid human errors, it is important to verify that the correct network interface, SFP module, or fiber optic cable is being replaced or troubleshooted. VMware administrators can retrieve neighbor details from the ESXi end using nsxcli, vim-cmd commands, or the GUI.

CDP-LLDP Neighbor from ESXCLI

Note: CDP/LLDP must be enabled from the Physical Switch end as well vCenter virtual distributed switch [VDS]end.

Disclaimer: Outputs are not accurate because the environment I am using is a nested lab in a physical environment you will get the accurate information.

Before querying neighbor details, ensure that CDP or LLDP is enabled on the required vSwitch or distributed switch. Here’s how you can do it:

Enabling CDP or LLDP on a Distributed Switch

1. Log in to the vSphere Web Client.

2. Navigate to Networking.

3. Select your distributed switch and go to Settings > Advanced.

Under Discovery Protocol, choose either CDP or LLDP and set the operation mode to Listen, Advertise, or Both.

01-vNetes_VDS_Discovery_Protocol_Configuration

Enabling CDP or LLDP on a Physical Switch

Before querying neighbor details, ensure that CDP or LLDP is enabled on the required TOR Switches. Here’s how you can do it:

!Verifying CDP on Cisco Switches 

TOR-01# show cdp neighbors

TOR-01# show cdp neighbors details

!Enable CDP on Cisco Switches

TOR-01(config)# cdp run

TOR-01(config-if)# cdp enable 

!Verifying LLDP on Cisco Switches 

TOR-01# show lldp neighbors

TOR-01# show lldp neighbors details

!Enable LLDP on Cisco Switches

TOR-01(config)# lldp run

TOR-01(config-if)# lldp transmit

TOR-01(config-if)# lldp receive

Get ESXi neighbor details using GUI.

Step 1: Login into vCenter and locate the ESXi host want to know the neighbor where the ESXi physical NIC is connected to TOR switches.

Step2: ESXi Host --> Configure --> Physical Adapters --> vmnic0 [Name of the NIC want know the neighbor details] --> Expand the arrow [<<] --> Navigate to CDP / LLDP tab to capture the details of neighbor TOR Switch. [Refer the artifacts]

Get ESXi neighbor details using GUI.

Get ESXi neighbor details using GUI vmnic0

Get ESXi neighbor details using CLI.

Option 1: The vim-cmd utility is a command line tool for managing various aspects of ESXi hosts. Now using vim-cmd to check CDP or LLDP information:

Step 1: SSH into the ESXi host and Run the following command:

[root@esxi-1:~] esxcfg-nics -l

[root@esxi-1:~] vim-cmd hostsvc/net/query_networkhint

Get ESXi neighbor details using CLI vim-cmd

This command returns detailed information about the connected network, including CDP/LLDP data for each physical NIC.

Step 2: Parse the output to find neighbor details such as the switch name, port ID, and other relevant information for the specific interface run the below command.

Tip: Replace vmnicx which do you want to know neighbor details on the below command.

[root@esxi-1:~]  vim-cmd hostsvc/net/query_networkhint --pnic=vmnic0 | egrep -E 'Port Description|System Name|System Description|value|chassisId|portId'

Get ESXi neighbor details using CLI filter with vmnic

Note: Option 2 only works if the ESXi host is prepared for the NSX and the below command won't work for NSX-v environment.

Option 2: The nsxcli utility is a command line tool for managing various aspects of ESXi transport host nodes. Now using nsxcli to check CDP or LLDP information:

Step 1: SSH into the ESXi host and Run the following command:

[root@esxi-1:~] esxcfg-nics -l

[root@esxi-1:~] nsxcli -c get lldp neighbors

vNetes_get_lldp_neighbors

This command returns detailed information about the connected network, including CDP/LLDP data for each physical NIC.

Step 2: Parse the output to find neighbor details of the specific vmnic using the below command.

Tip: Replace vmnicx which do you want to know neighbor details on the below command.

[root@esxi-1:~] nsxcli -c get lldp neighbors vmnic0

03-vNetes_get_lldp_neighbors_Specific_Interface

“Information is power. But like all power, there are those who want to keep it for themselves.”

― Aaron Swartz

I hope this information is useful for you. Please forgive any typos or incomplete sentences.

Thanks for Visiting vNetes.com

Post a Comment (0)
Previous Post Next Post