Loading

×Sorry to interrupt
CSS Error

Refresh

Cookie Preference Center

General Information on cookies

When you visit our website, we use cookies to ensure that we give you the best experience. This information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience on the site and the services we are able to offer. Further information can be found in our

Cookie Policy.

Strictly Necessary

Strictly Necessary

Always Active

Strictly Necessary

Strictly necessary cookies are always enabled since they are essential for our website to function. They enable core functionality such as security, network management, and website accessibility. You can set your browser to block or alert you about these cookies, but this may affect how the website functions. For more information please visit www.aboutcookies.org or www.allaboutcookies.org.

Cookie Details‎

Performance

Performance

Performance

Performance cookies are used to analyze the user experience to improve our website by collecting and reporting information on how you use it. They allow us to know which pages are the most and least popular, see how visitors move around the site, optimize our website and make it easier to navigate.

Cookie Details‎

Please confirm your settings by refreshing the page.

Functional

Functional

Functional

Functional cookies help us keep track of your past browsing choices so we can improve usability and customize your experience. These cookies enable the website to remember your preferred settings, language preferences, location and other customizable elements such as font or text size. If you do not allow these cookies, then some or all of these services may not function properly.

Cookie Details‎

Advertising

Advertising

Advertising

Advertising cookies are used to send you relevant advertising and promotional information. They may be set through our site by third parties to build a profile of your interests and show you relevant advertisements on other sites. These cookies do not directly store personal information, but their function is based on uniquely identifying your browser and internet device.

Cookie Details‎

Advertising Cookies

Consent Leg.Interest

Select All Vendors

Select All Vendors

Select All Hosts

Select All

Clear Filters

Information storage and access

Apply

Confirm My Choices Reject All Allow All

My Subscriptions

Loading

Knowledge Base

Configuring vSwitch or vNetwork Distributed Switch from the command line in ESXi/ESX (1008127)

Last Updated: 8/23/2023Categories: How toTotal Views: 101435Language:
Chinese (Simplified)Portuguese (European)JapaneseSpanishEnglish

70 like this article

Subscribe to get an email
newsletter with new updates

70 people found this helpful Please provide article feedback:

Learn how VMware Skyline Advisor and Skyline Health Diagnostics work together to provide proactive intelligence and self-service log analysis.

Use Skyline Advisor to avoid issues before they occur across VCF, vSphere, vSAN, NSX, vROps & Horizon. Skyline Findings are based on top KBs, VMSAs/CVEs and design best practices.

Use Skyline Health Diagnostics to root cause vSphere & vSAN logs when an issue occurs. Skyline Health Diagnostic Findings are based on top KBs and VMSA/CVEs. You can use the Skyline Health Diagnostics tool in online or offline mode.

If you require additional help from technical support, please use Skyline Advisor to initiate a Log Assist to reduce time to upload logs. TSEs can also initiate logs to reduce effort.

Symptoms

You are unable to connect to an ESXi/ESX host via the network because uplinks (vmnics) have changed or are not in the correct order

The Primary Service Console/VMkernel management interface is moved from a switch to a distributed switch on a non-routable network

VLAN for the Management Network is changed or configured incorrectly on the uplink Switch Port

Purpose

This article provides commands and information to restore management network connectivity via the correct vmnic interface.
See also: vCenter network connectivity lost - Recover vCenter network when connected to a Distributed Switch

Resolution

Notes:

You can restore the network to a Standard vSwitch using the Restore Standard Switch option from the Direct Console User Interface (DCUI) console screen (press F2 from console). This results in a blank network configuration (1 x vSwitch with 1 x vmkernel port group) on the ESXi host. Any existing vSwitch, portgroup, and VMkernel information is removed. VMware recommends taking a screenshot of your network configuration from the vSphere Client or saving the output from the esxcfg-vswitch -l and esxcfg-vmknic -l commands before using this option.

In ESXi 5.x and above

Note: In ESXi 5.x, most of the legacy commands used in 4.x will continue to work. VMware recommends using their esxcli equivalents where possible as legacy esxcfg commands will be deprecated in a future release.

To restore the Management vmkernel interface to the correct vmnic interface:

View the current vSwitch configuration and vmkernel interface configuration using these commands:

esxcli network vswitch standard list # list current vswitch configuration
esxcli network vswitch dvs vmware list # list Distributed Switch configuration
esxcli network ip interface list # list vmkernel interfaces and their configuration
esxcli network nic list # display listing of physical adapters and their link state

Add or remove network cards (known as vmnics) to or from a Standard vSwitch using these commands:

esxcli network vswitch standard uplink remove --uplink-name=vmnic --vswitch-name=vSwitch # unlink an uplink
esxcli network vswitch standard uplink add --uplink-name=vmnic --vswitch-name=vSwitch # add an uplink

Add or remove network cards (known as vmnics) to or from a vNetwork Distributed Switch (vDS) using these commands:

esxcfg-vswitch -Q vmnic -V dvPort_ID_of_vmnic dvSwitch # unlink/remove a vDS uplink
esxcfg-vswitch -P vmnic -V unused_dvPort_ID dvSwitch # add a vDS uplink

Note: If connectivity was lost when migrating management networking to a Distributed Switch, it may be necessary to remove or disable the existing management vmkernel interface and recreate it in a Standard vSwitch port group with the same IP configuration.

On a vSphere Distributed Switch (vDS), delete an existing VMkernel port using this command:

esxcli network ip interface remove --interface-name=vmkX

Note: The vmk interface number used for management can be determined by running the esxcli network ip interface list command.

After the unreachable vmkernel port has been removed, it can be recreated on a Standard Switch.

If an existing Standard Switch does not exist, you can create a new one as well as a port-group to use with these commands:

esxcli network vswitch standard add --vswitch-name=vSwitch
esxcli network vswitch standard portgroup add --portgroup-name=portgroup --vswitch-name=vSwitch

Note: When creating a virtual switch, there are no linked vmnics by default. You will need to link vmnics as described earlier in this article. Additionally, follow Linux best practices when creating via CLI, avoiding special characters.

To create a VMkernel port and attach it to a portgroup on a Standard vSwitch, run these commands:

esxcli network ip interface add --interface-name=vmkX --portgroup-name=portgroup
esxcli network ip interface ipv4 set --interface-name=vmkX --ipv4=ipaddress --netmask=netmask --type=static

Note: By default, the ESXi, the management vmkernel port is vmk0 and resides in a Standard Switch portgroup called Management Network.

If the vmnics associated with the management network are VLAN trunks, you may need to specify a VLAN ID for the management portgroup. To set or correct the VLAN ID required for management connectivity on a Standard vSwitch, run this command:

esxcli network vswitch standard portgroup set -p portgroup --vlan-id VLAN

It may be necessary to restart the host's management agents if network connectivity is not restored despite a correct configuration:

services.sh restart

Note: The command-line tool provides limited functionality when running the esxcfg-vswitch command with a vNetwork Distributed Switch. For example, you cannot create a dvportgroup or assign VLAN IDs to dvportgroups using this command. Some tasks must be completed from vCenter Server using the vSphere Client or vSphere Web Client.

Related Information

VMware Skyline Health Diagnostics for vSphere - FAQ

Configuring a VLAN on a portgroup (1003825)

Configuring networking from the ESX service console command line (1000258)

Specifying or changing the NIC teaming policy from the command line in ESX/ESXi 4.x and ESXi 5.x (1019864)

Configuring networking from the ESX service console command line
Configuring a VLAN on a portgroup
Specifying or changing the NIC teaming policy from the command line in ESX/ESXi 4.x and ESXi 5.x
Configuring or restoring networking from the ESX service console using console-setup
Understanding network rollback and recovery in vSphere 5.1 and later
Como configurar o vSwitch ou switch distribuído de vNetwork a partir da linha de comando no ESXi/ESX
Configuración del conmutador distribuido vSwitch o vNetwork desde la línea de comandos en ESXi/ESX
ESXi/ESX のコマンド ラインから vSwitch または vNetwork Distributed Switch を構成する
通过 ESXi/ESX 中的命令行配置 vSwitch 或 vNetwork Distributed Switch
VMware ESXi 5.1 Update 2 で 仮想スイッチまたはポートグループの削除が次のエラーで失敗する： Call "HostNetworkSystem.UpdateNetworkConfig" for object "networkSystem-XX" on vCenter Server "vc_name" failed

Detectable by VMware SkylineTM

Actions

Copy

link to clipboard
copied!

Print

Language:
Chinese (Simplified)Portuguese (European)JapaneseSpanishEnglish

Attachments

Additional Resources

No results for undefined

Ask The Community

Get answers quickly from VMware experts in the community

Post Subject

CONTINUE IN COMMUNITIES

Related Products:

VMware vSphere ESXi

Related Versions:

Take Our Survey

Support Assistant