Configuring VLAN on a vSwitch standard portgroup
search cancel

Configuring VLAN on a vSwitch standard portgroup

book

Article ID: 311057

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere ESXi

Issue/Introduction

This article provides information on adding and removing VLAN IDs to and from a portgroup.

Note: Making changes management VMkernel in ESXi from either the vSphere Client or an SSH session may cause the host to lose management network connectivity. When working on management VMkernel portgroups, it is best to use a remote console (such as ILO, DRAC, or an equivalent), or to work at the physical console of the server.

Symptoms:
  • Loss of network connectivity to and from the ESXi/ESX host
  • Loss of connectivity to associated portgroups

Environment

  • VMware vCenter Server 6.x
  • VMware ESXi 6.x
  • VMware vCenter Server 7.x
  • VMware ESXi 7.x
  • VMware vCenter Server 8.x
  • VMware ESXi 8.x

Resolution

Changing the VLAN ID using the vSphere UI

  1. Click the ESXi host and click the Configure tab.
  2. Under Networking, select Virtual Standard Switches.
  3. In the right panel, click on the PortGroup to be modified.
  4. Click on 3 dots next to PortGroup name & select Edit Settings.
  5. Under Properties select the appropriate value in the VLAN ID field (enter 0 for no VLAN).
  6. Click OK.

To change the VLAN ID using the Esxi Host Client:

  1. Log into the Esxi host client with root credentials in the browser like "https://esxi-host.domain.com"
  2. In the left side under Networking, and select Virtual Standard Switch.
  3. In the vSwitch topology diagram of the switch, click the name of the port group.
  4. Click Edit under the topology diagram title.
  5. In the Properties section, Configure VLAN tagging in the VLAN ID drop-down menu.

To change the VLAN ID at the Esxi host using the command line

  1. Log into ESXi host as root via SSH, remote console, or at the physical console.
    For more information, see:  Using ESXi Shell in ESXi
  2. To view the current configuration of the virtual switches, run the command:
        esxcfg-vswitch -l

    The output appears similar to:

    Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks

             vSwitch0                2990              3                 128                        8000    #####0

            PortGroup Name                            VLAN ID   Used Ports     Uplinks

            VM Network                                    110                 0               #####0

Note: Your virtual switch and PortGroup names may be different.
 

  1. Record the name of the virtual switch and PortGroup that you want to change.
  2. To change the VLAN ID on a PortGroup, run the command:
    esxcfg-vswitch -p "portgroup_name" -v VLAN_ID virtual_switch_name

    Where portgroup_name is the name of your portgroup, and virtual_switch_name is the name of your virtual switch.

    For example, using the configuration above, to add a VLAN ID of 111 to VM Network (which resides on vSwitch0), you must run the command:

     esxcfg-vswitch -p "VM Network" -v 111 vSwitch0
     
  3. To verify the new configuration, run the command:

    esxcfg-vswitch -l

    The output appears similar to:

           Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks

             vSwitch0                2990                 3                    128                           8000    vmnic0

             PortGroup Name                            VLAN ID  Used Ports  Uplinks

              VM Network                                     111         0                   vmnic0

To resolve connectivity and configuration issues, use these commands to link or unlink on Standard vSwitches

    • To unlink an uplink:

      esxcfg-vswitch -U vmnic vSwitch
       
    • To add an uplink:

      esxcfg-vswitch -L vmnic vSwitch

Additional Information