How To Configure ESXi Networking using Command Line



In my last blog, we discussed about esxcfg-nics  -l and esxcfg-vswitch -l  commands. In continuation of that, I will be explaining few of the useful vSwitch commands frequently used to configure and management vSphere Standard Switch Networking.

Esxcfg-vswitch is one of the important API used to Configure, Manage and Troubleshoot Networking issues.

In this Blog, we will be setting up basic network configuration using ESXCFG-VSWITCH CLI commands



Step 1:  List All vSwitches Information Created on ESXi Host

Cmd : 
esxcfg-vswitch -l 



 This command displays information about all the vswitches created on ESXi Host. For more details on vSwitch and Its Functionalities click here.

Step 2:  Create New vSwitch 

Cmd : 
esxcfg-vswitch -a <vSwitch_Name>


esxcfg-vswitch -a

In above example, I’ve created new vswitch called TestvSwitch with default 128 Configured ports out of which only 1 Port is active. This vSwitch is having default MTU size 1500 bytes & No Uplinks assigned to it.


Step 3:  Add New PortGroup 

Cmd : 
esxcfg-vswitch -A  <PortGroup_Name> <vSwitch_Name>


Add New Portgroup to vSwitch

This command creates new Portgroup called TestPG. For more information on Portgroup and other terminology, click here.


Step 4:  Assign Uplink to vSwitch

Cmd : 
esxcfg-vswitch -L <Uplink_Name> <vSwitch_Name>


esxcfg-vswitch -L

This command assigns uplink vmnic3 to TestvSwitch which means any VMs or VMKNIC running on TestvSwitch can communicate to external world or VMs running on different switch only using this uplink (vmnic3).


Step 5:  Assign VLANs to PortGroups

Cmd : 
esxcfg-vswitch -v <VLAN_ID>  -p <PortGroup_Name> <vSwitch_Name>


esxcfg-vswitch -v

This command assign VLAN ID 100 to TestPG Portgroup. In Similar way, you can create multiple Portgroups and assign different VLAN ID to each Portgroup.

In below example, I have create 5 different network assigned with different VLANs to isolate traffic.


esxcfg-vswitch -v multipleVLAN


Step 6:  Change vSwitch MTU Size

Cmd : 
esxcfg-vswitch -m <MTU_Size> <vSwitch_Name>


esxcfg-vswitch -m

This command changes the MTU size of vSwitch from default value of 1500 Bytes to 9000 Bytes. Any Ethernet frame configured with MTU_Size of 9000 bytes is referred as JUMBO FRAME.
With this command, we have configured our vSwitch to support JUMBO FRAMES for improving network performance.

At this point, we have setup basic network configuration required for VMs to communicate with each other or external world.

Next few commands will be related to wiping out network configuration.


Step 7:  Remove VLAN Configuration or Restore default Configuration

Cmd : 
esxcfg-vswitch -v 0 -p <Portgroup_Name> <vSwitch_Name>


esxcfg-vswitch -v delete VLAN

VLAN Configuration can be wiped out or deleted by setting up VLAN ID back to 0.


Step 8:  Remove JUMBO FRAME Configuration from vSwitch

Cmd : 
esxcfg-vswitch  -m 1500  -p <Portgroup_Name> <vSwitch_Name>


esxcfg-vswitch -m delete MTU

Setting MTU Size Back to 1500 remove Jumbo Frame Configuration and restore switch to default MTU size.

Step 9:  Remove UPLINK from vSwitch

Cmd : 
esxcfg-vswitch  -U <Uplink_Name> <vSwitch_Name>


esxcfg-vswitch -U Remove Uplink

This command removes uplink vmnic3 from vSwitch which means none of the VMs or VMKNIC Traffic will be able to communicate to external world. Traffic will not go out of the vSwitch.

Just to remind you, In above mentioned configuration VMs running on TestvSwitch will still be able to talk to each other even though no Uplink assigned to TestvSwitch.

I am hoping you guys would definitely be knowing the reason for this.


Step 10:  Remove PORTGROUPS  from vSwitch

Cmd : 
esxcfg-vswitch  -D <PortGroup_Name> <vSwitch_Name>


esxcfg-vswitch -D Delete Portgroup

This command deletes TestPG portgroup.


Step 11:  Remove vSwitch

Cmd : 
esxcfg-vswitch  -d  <vSwitch_Name>


esxcfg-vswitch -d Delete vSwitch

This command deletes vSwitch TestvSwitch.



In this article, we learned how vSphere Networking can be configured on ESXi Host using esxcfg-* Command Line.

I hope you guys might have found this article useful.

Please don’t forget to share your comments or feedback or any queries related to it.


govmlab on Emailgovmlab on Facebookgovmlab on Googlegovmlab on Linkedingovmlab on Twitter
VMware Solution Architect
I am VMware Solution Architect with 10+ Years of enriching experience in Datacenter Virtualization Technologies, Storage Area Networks and Software Defined Datacenter, Networking and Storage.
I hold Numerous certification including RHCE, CCNA, VCP4.0, VCP5.1, VCP5.5, vCloud and EMC certification.
While spending countless hours exploring the product inside and out and learning everything about it, Eventually I discovered my passion for teaching and helping others learn from my knowledge and experience so turned to Trainer cum Blogger to educate every single person keen to learn Virtualization.

Leave a Reply