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
HOW TO CONFIGURE ESXi NETWORKING USING COMMAND LINE
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>
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>
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>
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>
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.
Step 6: Change vSwitch MTU Size
Cmd : esxcfg-vswitch -m <MTU_Size> <vSwitch_Name>
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>
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>
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>
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>
This command deletes TestPG portgroup.
Step 11: Remove vSwitch
Cmd : esxcfg-vswitch -d <vSwitch_Name>
This command deletes vSwitch TestvSwitch.
CHECK OUT BELOW VIDEO ON VIRTUAL NETWORKING COMMANDS
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.