Setting the Port Group VLAN ID with ESXCLI

You can use esxcli network vswitch standard portgroup set to manage VLANs.

VLANs allow you to further segment a single physical LAN segment so that groups of ports are isolated as if they were on physically different segments. The standard is IEEE 802.1Q.

A VLAN ID restricts port group traffic to a logical Ethernet segment within the physical network.

  • Set the VLAN ID to 4095 to allow a port group to reach port groups located on other VLAN.
  • Set the VLAN ID to 0 to disable the VLAN for this port group.

If you use VLAN IDs, you must change the port group labels and VLAN IDs together so that the labels properly represent connectivity. VLAN IDs are optional.

You can use the following commands for VLAN management.

  • Allow port groups to reach port groups located on other VLANs.
    esxcli <conn_options> network vswitch standard portgroup set -p <pg_name> --vlan-id 4095
    Run the command multiple times to allow all ports to reach port groups located on other VLANs.
  • Disable VLAN for port group g42.
    esxcli <conn_options> network vswitch standard portgroup set --vlan-id 0 -p g42

Run esxcli network vswitch standard portgroup list to list all port groups and associated VLAN IDs.