Esxcfg-vswitch Commands

Images
For us Unix guys, the idea of doing everything in ESX via a GUI is very hard to swallow. Especially when it comes to repetitive tasks like setting up vSwitches and Port Groups. Sure you can spend and arm and a leg on Enterprise Advanced licenses so that you can have distributed switches, but why when you can just script your commands and run that script on each box in your cluster. Below are a few examples of how to use the esxcfg-vswitch command.

Delete a Port Group:

esxcfg-vswitch -D “Service Console” vSwitch1

Add a nic (vmnic2) to a vswitch (vswitch1):

esxcfg-vswitch -L vmnic2 vswitch1 


Remove a pnic (vmnic3) from a vswitch (vswitch0):

esxcfg-vswitch -U vmnic3 vswitch0


Create a portgroup (VM Network3) on a vswitch (vswitch1):


esxcfg-vswitch -A “VM Network 3” vSwitch1


Assign a VLAN ID (3) to a portgroup (VM Network 3) on a vswitch (vswitch1):


esxcfg-vswitch -v 3 -p “VM Network 3” vSwitch1

Change your Service Console (vswif0) IP and Subnet Mask:


esxcfg-vswif -i 172.20.20.5 -n 255.255.255.0 vswif0

Add a Service Console (vswif0):


esxcfg-vswif -a vswif0 -p “Service Console” -i 172.20.20.40 -n 255.255.255.0

Add Vlan to a Port Group:

esxcfg-vswitch “vSwitch name” -p “portgroup name” -v “vlan ID”

List the existing config so you can get your vswitch and portgroup name:

esxcfg-vswitch -l

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s