[Home] [Forum] [3i RCLI Guide]

The commands vicfg-vswitch.pl (esxcfg-vswitch.pl) are used to manage virtual switches and port groups. A virtual switch is used to provide network connectivity between virtual machines and to link those VMs to the rest of your network. By default your ESXi host will be installed with a single virtual switch (vSwitch) called vSwitch0. vSwitch0 will have 2 port groups attached to it - one for management and another for VM traffic. The following are options for the vicfg-switch.pl command.

--list (-l) -- This option lists all vSwitches and port groups on the host.
--check <vSwitch_name> (-c <vSwitch_name>) -- Checks to see if a vSwitch exists - the output will be 1 if true and 0 if the vSwitch doesn't exist.
--add <vSwitch_name> (-a <vSwitch_name>) -- Adds the specified vSwitch to your host.
--delete <vSwitch_name> (-d <vSwitch_name>) -- This option deletes a vSwitch. It will fail if any port groups are in use by the VMkernel or virtual machines.
--check-pg <portgroup_name> (-C <portgroup_name>) -- Checks to see if a port group exists.
--add-pg <portgroup_name> <vSwitch_name> (-a <portgroup_name> <vSwitch_name>) -- Adds a port group to the specified vSwitch.
--del-pg <portgroup_name> (-D <portgroup_name>) -- This option deletes a port group. It will fail if the port group is in use by the VMkernel or virtual machines.
--link <vmnic> (-L <vmnic>) -- Links a physical NIC port to a vSwitch. If no vmnic is specified then all unused NIC ports are linked to the vSwitch.
--unlink (vmnic> (-U <vmnic>) -- Removes a physical NIC from a virtual switch.
--mtu <mtu_value> <vSwitch_name> (-m <mtu_value> <vSwitch_name>) -- This option sets the maximum transmission unit (MTU) for the vSwitch. This option affects all physical NIC ports linked to the vSwitch. Note that all physical NICs linked to the vSwitch must support the MTU value specified. The MTU value can not be set at this time via the VI client.
--vlan <vlan_ID> -- pg <portgroup_name> <vSwitch_name> (-v <vlan_ID> -p <portgroup_name> <vSwitch_name>) -- Sets a VLAN ID for the specified port group. If you specify 0, the VLAN ID for the port group will be disabled.

Sample Session

vicfg-vswitch.pl --server 192.168.1.80 --username root --list

Switch Name    Num Ports     Used Ports      Configured Ports      MTU      Uplinks
vSwitch0       64            4               64                    1500     vmnic0

PortGroup Name           VLAN ID      Used Ports      Uplinks
VM Network               0            1               vmnic0
Management Network       0            1               vmnic0

vicfg-vswitch.pl --server 192.168.1.80 --username root --check vSwitch1
0

vicfg-vswitch.pl --server 192.168.1.80 --username root --check vSwitch0
1

vicfg-vswitch.pl --server 192.168.1.80 --username root --add vSwitch1

vicfg-vswitch.pl --server 192.168.1.80 --username root --link vmnic1 vSwitch1
Update uplinks : vmnic1

vicfg-vswitch.pl --server 192.168.1.80 --username root --add-pg DMZ vSwitch1

vicfg-vswitch.pl --server 192.168.1.80 --username root --vlan 10 --pg DMZ vSwitch1

vicfg-vswitch.pl --server 192.168.1.80 --username root --mtu 9000 vSwitch1
Error during the configuration of the host: Unable to set MTU to 9000 the follow
uplinks refused the MTU setting: vmnic1

vicfg-vswitch.pl --server 192.168.1.80 --username root --mtu 1300 vSwitch1

vicfg-vswitch.pl --server 192.168.1.80 --username root --list

Switch Name    Num Ports     Used Ports      Configured Ports      MTU      Uplinks
vSwitch0       64            4               64                    1500     vmnic0

PortGroup Name           VLAN ID      Used Ports      Uplinks
VM Network               0            1               vmnic0
Management Network       0            1               vmnic0

Switch Name    Num Ports     Used Ports      Configured Ports      MTU      Uplinks
vSwitch1       64            2               64                    1500     vmnic1

PortGroup Name           VLAN ID      Used Ports      Uplinks
DMZ                      10           1               vmnic1

The changes made with the vicfg-vswitch.pl command may also be make with the VI client. Go to Configuration \ Networking and click on Add Networking to create a new vSwitch. Click on properties of an existing vSwitch to add a port group or to link / unlink a network port from the vSwitch.


INSERT YOUR COMMENT - IF YOU HAVE A QUESTION PLEASE USE THE FORUM


Name (required)

Web Site (optional)

Email address (required - will not be displayed)

Comment (required)

Please enter code

 

Copyright © 2011 - Dave Mishchenko