Recover ESXi host connectivity when management is on DVS
search cancel

Recover ESXi host connectivity when management is on DVS

book

Article ID: 386467

calendar_today

Updated On: 02-05-2025

Products

VMware vSphere ESXi

Issue/Introduction

An ESXi host has become disconnected and is only accessible via command line or DCUI console (vCenter may or may not be accessible at this point in time either) and the host is still associated with the DVS. 

Cause

  • Unable to connect to an ESXi/ESX host via the network because uplinks (vmnics) have changed or are not in the correct order
  • Misconfiguration for the VLAN on the Management Network and the host is no longer connected
  • The primary vmkernel adapter used for the hosts management interface has been moved from a vSwitch to a DVS which is using a non-routable network
  • The NICs that the ESXi management interface uses are down

 

Resolution

***Note: If using LACP, prior to continuing the troubleshooting steps below, ensure LACP protocol is disabled and the LAG is broken as LACP is not supported on a standard switch***

If vCenter is accessible and a backup of the DVS is needed refer to this document: Export the Configuration of the vSphere Distributed Switches 

  1. Ensure you have all the IP configuration details of the vmkernel adapter for the host before proceeding with the migration/configuration changes
    • If vCenter is still accessible you may be able to view this information by clicking on the host > configure > VMkernel Adapters > and expanding the vmk information will show the settings/configurations for that specific vmkernel adapter
    • If the vCenter is not accessible the following command can show you the some of the basic information about the vmkernel adapter: esxcfg-vmknic -l
    • Specifically the information needed for the vmkernel adapter is:
      • IP (whether you're using IPv4 or IPv6)
      • Subnet mask
      • Default Gateway
      • MTU size
      • VLAN (if the physical switch port is set to "Trunked" then the ESXi portgroup will need to have the VLAN tag added to it) 
  2. Verify if the ESXi host already has a vSwitch or if one will need to be created by running the command esxcfg-vswitch -l
    • A standard switch will show as "Switch Name" whereas a distributed switch will show as "DVS Name"
    • Note if the DVS does not have multiple NICs then all networking on the host will be disconnected once the NIC is removed from the DVS 
      1. If your host is only showing DVS then you will need to build the vSwitch via command line by following this process:
        • Run the command esxcli network vswitch standard add --vswitch-name=vSwitch#
          • To confirm it's been created run the command esxcfg-vswitch -l 
  3. Remove one of the vmnics from the DVS
    • Run the command esxtop and then type the letter "n" on your keyboard to view the NICs in-use (note that this command will show what NIC is being leveraged by any VMs or  vmkernel adapters on the host in real time) then press "q" to go back to the command line:
    • For this example we see that vmk0 (the host's management vmkernel adapter) is currently using vmnic1. Before removing the NIC from the DVS make sure that whichever NIC to be used on the standard switch is configured to pass management traffic (for example a specific VLAN).  
    • Run the command esxcfg-vswitch -l to identify the DVPort ID of the NIC that will be removed (8 in the below screenshot):
    • Run the following command: esxcfg-vswitch -Q vmnic# -V Port-ID DVS-name.
      • Example using the screenshot information above:
        • esxcfg-vswitch -Q vmnic1 -V 8 DSwitchNameHere.
      • Verify that the NIC has been removed from the vDS by running the command esxcfg-vswitch -l:
  4. Associate the NIC with the vSwitch (standard switch)
      • Run the command: esxcli network vswitch standard uplink add --uplink-name=vmnic# --vswitch-name=vSwitch#
      • Verify that the NIC is now associated with the vSwitch by running the command esxcfg-vswitch -l
  5. Create a portgroup on the vSwitch with the same configuration as the DVS portgroup for the hosts management
    • Run the command esxcli network vswitch standard portgroup add --portgroup-name=EnterPortGroupNameHere --vswitch-name=vSwitch#
    • If the management network requires a VLAN tag add in the VLAN into the ESXi standard portgroup:
      • esxcli network vswitch standard portgroup set ---portgroup-name=EnterPortGroupNameHere --vlan-id=###
  6. Delete the current management vmkernel adapter and then recreate it on the vSwitch
    • Run the following command to delete the VMK (normally the management vmkernel adapter is usually vmk0 but your environment may different, verify before deleting):
      • esxcli network ip interface remove --interface-name=vmk#
    • Run the following command to create a new VMK:
      • esxcli network ip interface add --interface-name=vmk# --portgroup-name=EnterPortGroupNameHere
  7. Configure the new adapter with the same information from the previous configuration (IP, Subnet, MTU etc.)
    • Run the command
      • esxcli network ip interface ipv4 set --interface-name=vmk# --ipv4=###.###.#.### --netmask=###.###.###.### -g=###.#.###.## --type=static
      • IPv4 is the IP for the vmkernel adapter, netmask is the subnet mask used, -g is the default gateway
      • Note: If you are using IPv6 instead of IPv4, simply change the command to specify IPv6 where IPV4 is listed
      • To add the MTU size run the command: esxcli network ip interface set -m=### --interface-name=vmk#
  8. Verify the ESXi host is now reachable over the network

Additional Information