Friday, August 27, 2010

ESX CLI

Creating, Configuring, and Deleting vSwitches

You’ll primarily use the esxcfg-vswitch command for the majority of these tasks. Unless I specifically indicate otherwise, all the commands, parameters, and arguments are case-sensitive.

To create a vSwitch, use this command:

esxcfg-vswitch -a

To link a physical NIC to a vSwitch—which is necessary in order for the vSwitch to pass traffic onto the physical network or to receive traffic from the physical network—use this command:

esxcfg-vswitch -L

In the event you don’t have information on the physical NICs, you can use this command to list the physical NICs:

esxcfg-nics -l (lowercase L)

Conversely, if you need to unlink (remove) a physical NIC from a vSwitch, use this command:

esxcfg-vswitch -U

To change the Maximum Transmission Unit (MTU) size on a vSwitch, use this command:

esxcfg-vswitch -m

To delete a vSwitch, use this command:

esxcfg-vswitch -d

Creating, Configuring, and Deleting Port Groups
As with virtual switches, the esxcfg-vswitch is the command you will use to work with port groups. Once again, unless I specifically indicate otherwise, all the commands, parameters, and arguments are case-sensitive.

To create a port group, use this command:

esxcfg-vswitch -A

To set the VLAN ID for a port group, use this command:

esxcfg-vswitch -v -p

To delete a port group, use this command:

esxcfg-vswitch -D

To view the current list of vSwitches, port groups, and uplinks, use this command:

esxcfg-vswitch -l (lowercase L)


Here are a few of the really useful ones I have gotten comfortable with

◦Add a vswitch – ” esxcfg-vswitch -a vSwitch4 “

◦Add a portgroup – ” esxcfg-vswitch -A "My New Portgroup" vSwitch4 “

◦Add a VLAN tag – ” esxcfg-vswitch -p "My New Portgroup" -v 33 vSwitch4 “

◦Add a NIC to a vswitch – ” esxcfg-vswitch -L vmnic2 vSwitch4 “

◦Add a NIC to a portgroup – ” esxcfg-vswitch -M vmnic2 -p "My New Portgroup" vSwitch4 “

◦Remove a NIC from a portgroup – ” esxcfg-vswitch -N vmnic2 -p "My Old Portgroup" vSwitch4 “

◦Remove a portgroup – ” esxcfg-vswitch -D "My Old Portgroup" vSwitch4 “

◦List your vswitches – ” esxcfg-vswitch -l “

◦List your vswif NICs – ” esxcfg-vswif -l “

◦List your vmkernel NICs – ” esxcfg-vmknic -l “

◦List your physical NICs – ” esxcfg-nics -l “

◦Add a vswif to a portgroup – ” esxcfg-vswif -a vswif7 -i 10.11.12.3 -n 255.255.255.192 -p "My New Portgroup" “

◦Move a vswif to a different portgroup – ” esxcfg-vswif -p "new portgroup" vswif3 “

◦Add a vmkernel NIC – ” esxcfg-vmknic -a -i 10.12.13.4 -n 255.255.255.192 "My Other New Portgroup" “

◦Temporarily disable the firewall for troubleshooting purposes – ” esxcfg-firewall --allowIncoming --allowOutgoing “

No comments: