Friday, August 2, 2013

ESX 3.x Commands - Virtual Switch Commands

Virtual Switch Commands

Command Options:
/usr/sbin/esxcfg-vswitch
esxcfg-vswitch [options] [vswitch[:ports]]
-a|--add              Add a new virtual switch.
-d|--delete           Delete the virtual switch.
-l|--list             List all the virtual switches.
-L|--link=pnic        Set pnic as an uplink for the vswitch.
-U|--unlink=pnic      Remove pnic from the uplinks for the vswitch.
-M|--add-pg-uplink    Add an uplink to the list of uplinks for a portgroup
-N|--del-pg-uplink    Delete an uplink from the list of uplinks for a portgroup
-p|--pg=portgroup     Specify a portgroup for operation
Use ALL to set VLAN IDs on all portgroups
-v|--vlan=id          Set vlan id for portgroup specified by -p
0 would disable the vlan
-c|--check            Check to see if a virtual switch exists.
Program outputs a 1 if it exists, 0 otherwise.
-A|--add-pg=name      Add a new portgroup to the virtual switch.
-D|--del-pg=name      Delete the portgroup from the virtual switch.
-C|--check-pg=name    Check to see if a portgroup exists.  Program
outputs a 1 if it exists, 0 otherwise.
-B|--set-cdp          Set the CDP status for a given virtual switch.
To set pass one of "down", "listen", "advertise", "both".
-b|--get-cdp          Print the current CDP setting for this switch.
-m|--mtu=MTU          Set MTU for the vswitch. This affects all the nics attached on the vswitch.
-r|--restore          Restore all virtual switches from the configuration file
-h|--help             Show this message.

List all virtual switches and the port group information (ESX 3.x)
esxcfg-vswitch -l

output:
Switch Name    Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch0                    64                  9                     64                    1500    vmnic2,vmnic0
PortGroup Name      VLAN ID  Used Ports  Uplinks
Server Network                 41           5               vmnic0,vmnic2
Switch Name    Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch1                    64                  6                         64               1500     vmnic3,vmnic1
PortGroup Name      VLAN ID  Used Ports  Uplinks
Service Console           35                  1           vmnic1,vmnic3
VMkernel                        35                  1           vmnic1,vmnic3
Switch Name    Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch2                    64                     1                      64                1500
PortGroup Name      VLAN ID  Used Ports  Uplinks

Internal                               0                0

Delete a port group from a vswitch (ESX 3.x)
/usr/sbin/esxcfg-vswitch -D "Service Console" vSwitch1

Add a port group to a vswitch (ESX 3.x)
/usr/sbin/esxcfg-vswitch -A "Service Console" vSwitch1

Set the VLAN ID of a port group (ESX 3.x)
/usr/sbin/esxcfg-vswitch -p "Service Console" -v35 vSwitch1

Check if virtual switch already exists (ESX 3.x)
esxcfg-vswitch -c vSwitch2

Create a virtual switch (ESX 3.x)
esxcfg-vswitch -a vSwitch2

Check if a port group on a virtual switch already exists (ESX 3.x)
esxcfg-vswitch -C Vmotion

Create a port group on a virtual switch (ESX 3.x)
esxcfg-vswitch -A VMotion vSwitch2

Link a virtual switch to a physical nic (ESX 3.x)
esxcfg-vswitch -L vmnic2 vSwitch2

No comments:

Post a Comment