VMware vSphere ESXi 8.0.x
VMware vSphere ESXi 7.0.x
VMware vSphere ESXi 6.x
Notes:
To restore the Management vmkernel interface to the correct vmnic interface:
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
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
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.
esxcfg-route -a <default gateway ip>
After creating the vmkernel on the vSwitch, an appropriate tag can also be assigned to this vmkernel using following command.
esxcli network ip interface tag add --interface-name=vmkX --tagname=name of tag
add : Adds a tag on a given VMkernel network interface. Supported tags are : Management, VMotion, faultToleranceLogging,vSphereReplication, vSphereReplicationNFC, vSphereProvisioning, VSAN, VSANWitness, vSphereBackupNFC, PrecisionTimeProtocol, NVMeTCP, NVMeRDMA
get : Gets the tags set on the given VMkernel network interface.
remove : Removes a tag on a given VMkernel network interface.
-i|--interface-name=<str>
The name of the VMkernel network interface on which tags should be set. This name must be an interface listed in the interface list command. (required)
-t|--tagname=<str>
Tag name to assign to the interface (required)
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.
esxcfg-vswitch -m 9000 vswitch_name OR esxcli network vswitch standard set -m 9000 -v vswitch_name
esxcli network ip interface set -m 9000 -i vmkX
Note: If the VMkernel (VMK) interface, which is part of a vswitch, is configured to use Jumbo Frames, the vswitch it resides on must also be configured for Jumbo Frames.
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.
esxcli network ip interface ipv4 set –i vmk0 -t static –g IPv4 gateway -N mask
esxcli network vswitch standard portgroup set -p portgroup --vlan-id VLAN
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.