There are a few ways to troubleshoot network/VLAN configuration from a command line, using tools such as ESXCLI and vicfg/esxcfg either locally on the ESXi host or remotely using vCLI or the vMA. Here, I’ll aim to give examples using esxcfg commands ran from a vMA, and ESXCLI commands executed locally on the ESXi host.
Listing Port Group Settings
~ # esxcli network vswitch standard portgroup list Name Virtual Switch Active Clients VLAN ID ------------------ -------------- -------------- ------- Management Network vSwitch0 1 0 VM Network vSwitch3 0 0 vMotion vSwitch0 1 0
vi-admin@vma:~[192.168.88.134]> esxcfg-vswitch -l Switch Name Num Ports Used Ports Configured Ports MTU Uplinks vSwitch0 128 5 128 1500 vmnic1,vmnic0 PortGroup Name VLAN ID Used Ports Uplinks vMotion 0 1 vmnic1 Management Network 0 1 vmnic0 Switch Name Num Ports Used Ports Configured Ports MTU Uplinks vSwitch3 128 3 128 1500 vmnic7,vmnic6 PortGroup Name VLAN ID Used Ports Uplinks VM Network 0 0 vmnic7,vmnic6 DVS Name Num Ports Used Ports Configured Ports Uplinks DSwitch1 256 5 256 vmnic4,vmnic5,vmnic8,vmnic9 DVPort ID In Use Client 8 1 vmnic4 9 1 vmnic9 10 1 vmnic8 11 1 vmnic5 0 0 1 0
Configuring VLAN Tags
~ # esxcli network vswitch standard portgroup set -p vMotion --vlan-id 10 ~ # esxcli network vswitch standard portgroup list Name Virtual Switch Active Clients VLAN ID ------------------ -------------- -------------- ------- Management Network vSwitch0 1 0 VM Network vSwitch3 0 0 vMotion vSwitch0 1 10
vi-admin@vma:~[192.168.88.134]> esxcfg-vswitch vSwitch0 -p vMotion -v 0
Adding and Removing Port Groups
esxcli network vswitch standard portgroup add -p testpg -v vSwitch0 ~ # esxcli network vswitch standard portgroup set -p testpg --vlan-id 1000 ~ # esxcli network vswitch standard portgroup list Name Virtual Switch Active Clients VLAN ID ------------------ -------------- -------------- ------- Management Network vSwitch0 1 0 VM Network vSwitch3 0 0 testpg vSwitch0 0 1000 vMotion vSwitch0 1 0
esxcfg-vswitch --add-pg testpg vSwitch1
To delete a port group:
~ # esxcli network vswitch standard portgroup remove -p testpg -v vSwitch0 ~ # esxcli network vswitch standard portgroup list Name Virtual Switch Active Clients VLAN ID ------------------ -------------- -------------- ------- Management Network vSwitch0 1 0 VM Network vSwitch3 0 0 vMotion vSwitch0 1 0
esxcfg-vswitch --del-pg testpg vSwitch1