vicfg-vswitch - create and configure virtual switches and port groups
vicfg-vswitch [<connection_options>] [ --add <switch_name> | --check <vswitch_name> | --delete <vswitch_name> | --get-cdp <vswitch_name> | --help | --link <physical_nic> <vswitch_name> | --list | --mtu <vswitch_name> | --set-cdp <vswitch_name> | --unlink <physical_nic> <vswitch_name> | --vihost <esx_host ]
vicfg-vswitch [<connection_options>] [--add_pg <portgroup> <vswitch_name> | --check-pg <port_group> <vswitch_name> | --del-pg <port_group> <vswitch_name> | --help | --list | --vihost <esx_host | --vlan --pg <port_group> ]
vicfg-vswitch [<connection_options>] [--add-dvp-uplink <adapter_name> --dvp <DVPort_id> <dvswitch_name> | --del-dvp-uplink <adapter_name> --dvp <DVPort_id> <dvswitch_name> | --help | --vihost <esx_host ]
vicfg-vswitch [<connection_options>] [--add-pg-uplink <adapter_name> --pg <port_group> <vswitch_name> | --del-pg-uplink <adapter_name> --pg <port_group> <vswitch_name> | --help | --vihost <esx_host ]
The vicfg-vswitch command adds or removes virtual switches or modifies virtual switch settings. A virtual switch is an abstracted network device. It can route traffic internally between virtual machines and link to external networks. The ESX Configuration Guide and the ESXi Configuration Guide discuss virtual switches, vNetwork Distributed Switches (vDS), port groups, and vDS port groups. The vSphere CLI manual presents some sample scenarios.
By default,each ESX/ESXi host has a single virtual switch called vSwitch0.
Adds a new virtual switch.
Adds a port group to the specified virtual switch.
Adds an uplink adapter to a distributed virtual port (DVP).
Adds an uplink adapter to a port group (valid for vSphere 4.0 and later). This command fails silently if the uplink adapter does not exist.
Checks whether a virtual switch exists. Prints 1 if the switch exists and prints 0 otherwise. Use the virtual switch name, e.g. vSwitch0 or vSwitch1, to specify the virtual switch.
Checks whether the specified port group exists or not.
Specifies the target server and authentication information if required. Run vicfg-vswitch --help
for a list of all connection options.
Deletes a virtual switch. Running the command with this option fails if any ports on the virtual switch are in use by VMkernel networks, vswifs, or virtual machines.
Deletes a port group from the virtual switch. Running the command with this option fails if the port group is in use, for example, by a virtual machine or a VMkernel network.
Deletes an uplink adapter from a port on a DVS (distributed virtual switch), also called vNetwork Distributed Switch (vDS). Valid for vSphere 4.0 and later.
Deletes an uplink adapter from a port group. Valid for vSphere 4.0 and later.
Name of a distributed virtual port. Used in conjunction with other options. Valid for vSphere 4.0 and later.
Prints the current CDP (Cisco Discovery Protocol) setting for this virtual switch (valid for vSphere 4.0 and later).
Prints a help message for each command-specific and each connection option.
Calling the script with no arguments or with --help
has the same effect.
Adds an uplink adapter (physical NIC) to a virtual switch. Running the command with this option attaches a new unused physical network adapter to a virtual switch.
Lists all virtual switches and their port groups.
Sets the MTU (maximum transmission unit) of the virtual switch. This option affects all physical NICs assigned to the virtual switch.
Provides the name of the port group for the --vlan option. Specify ALL to set VLAN IDs on all port groups of a virtual switch.
Sets the CDP status for a given virtual switch (valid for vSphere 4.0 and later).
To set, specify down
, listen
, advertise
, or both
.
Removes an uplink adapter from a virtual switch. An uplink adapter corresponds to a physical Ethernet adapter to which the virtual switch is connected. If you remove the last uplink adapter, you lose physical network connectivity for that switch.
When you run a vSphere CLI command with the --server
option pointing to a
vCenter Server system, use
--vihost
to specify the ESX/ESXi host to run the command against.
Sets the VLAN ID for a specific port group of a virtual switch.
Setting the option to 0 disables the VLAN for this port group.
If you specify this option, you must also specify the --pg
option.
The following examples assume you are specifying connection options, either
explicitly or, for example, by specifying the server, user name, and password.
Run vicfg-vswitch --help
for a list of common options including connection options.
Add a new virtual switch:
vicfg-vswitch <conn_options> -a <vswitch name>
Delete the virtual switch. This will fail if any ports on the virtual switch are still in use by VMkernel networks, vswifs, or virtual machines:
vicfg-vswitch <conn_options> -d <vswitch name>
List all virtual switches and their portgroups:
vicfg-vswitch <conn_options -l
Add an uplink adapter to a virtual switch:
vicfg-vswitch <conn_options> -L <physical adapter name> <vswitch name>
Remove an uplink adapter from a virtual switch:
vicfg-vswitch <conn_options> -U <physical adapter name> <vswitch name>
Check whether a virtual switch exists:
vicfg-vswitch <conn_options> --check <vswitch name>
Add a new portgroup to the virtual switch:
vicfg-vswitch <conn_options> -A <port group name> <vswitch name>
Delete a portgroup from the virtual switch:
vicfg-vswitch <conn_options> -D <port group name> <vswitch name>
Check whether a port group exists:
vicfg-vswitch <conn_options> -C <valid portgroup name> <vswitch name>
Add an uplink adapter to a port group:
vicfg-vswitch <conn_options> -M <physical adapter name> -p <port group name> <vswitch name>
Remove an uplink adapter from a port group:
vicfg-vswitch <conn_options> -N <physical adapter name> -p <port group name> <vswitch name>
Print the current CDP setting for the virtual switch:
vicfg-vswitch <conn_options> --get-cdp <vswitch name>