7 Create or manipulate virtual switches using esxcli network vswitch or vicfg-vswitch. By default, each ESXi host has one virtual switch, vSwitch0. You can create additional virtual switches or manage existing switches. See Setting Up Virtual Switches and Associating a Switch with a Network Interface.
8 (Optional) Make changes to the uplink adapter using esxcli network vswitch standard uplink or vicfg-nics. See Managing Uplink Adapters.
9 (Optional) Use esxcli network vswitch standard portgroup or vicfg-vswitch to add port groups to the virtual switch. See Managing Port Groups with vicfg-vswitch.
10 (Optional) Use esxcli network vswitch standard portgroup set or vicfg-vswitch to establish VLANs by associating port groups with VLAN IDs. See Setting the Port Group VLAN ID with vicfg-vswitch.
11 Use esxcli network ip interface or vicfg-vmknic to configure the VMkernel network interfaces. See Adding and Modifying VMkernel Network Interfaces.A virtual switch models a physical Ethernet switch. You can manage virtual switches and port groups by using the vSphere Web Client (see the vSphere Networking documentation) or by using vSphere CLI commands.You can create a maximum of 127 virtual switches on a single ESXi host. By default, each ESXi host has a single virtual switch called vSwitch0. By default, a virtual switch has 56 logical ports. See the Configuration Maximums document on the vSphere documentation main page for details. Ports connect to the virtual machines and the ESXi physical network adapters.
■
■ You can connect the uplink adapter to the virtual switches by using vicfg-vswitch or esxcli network vswitch standard uplink. See Linking and Unlinking Uplink Adapters with vicfg-vswitch.When two or more virtual machines are connected to the same virtual switch, network traffic between them is routed locally. If an uplink adapter is attached to the virtual switch, each virtual machine can access the external network that the adapter is connected to.This section discusses working in a standard switch environment. See Networking Using vSphere Distributed Switches for information about distributed switch environments.
1
2
a
b
c
d You can retrieve information about virtual switches by using ESXCLI or vicfg-vswitch. Specify one of the options listed in Connection Options in place of <conn_options>.You can retrieve information about virtual switches by using esxcli network vswitch commands.The command prints information about the virtual switch, which might include its name, number of ports, MTU, port groups, and other information. The output includes information about CDP settings for the virtual switch. The precise information depends on the target system. The default port groups are Management Network and VM Network.
■ List the network policy settings (security policy, traffic shaping policy, and failover policy) for the virtual switch. The following commands are supported.You can retrieve information about virtual switches by using the vcifg-vswitch command. Specify one of the options listed in Connection Options in place of <conn_options>.
■ Check whether vSwitch1 exists.The command prints information about the virtual switch, which might include its name, number of ports, MTU, port groups, and other information. The default port groups are Management Network and VM Network.If CDP is enabled on a virtual switch, ESXi administrators can find out which Cisco switch port is connected to which virtual switch uplink. CDP is a link-level protocol that supports discovery of CDP-aware network hardware at either end of a direct connection. CDP is bit forwarded through switches. CDP is a simple advertisement protocol which beacons information about the switch or host and some port information.You can add and delete virtual switches with ESXCLI and with vicfg-vswitch.You can add and delete virtual switches using the esxcli network vswitch standard namespace. Specify one of the options listed in Connection Options in place of <conn_options>.You can specify the number of port groups while adding the virtual switch. If you do not specify a value, the default value is used. The system-wide port count cannot be greater than 4096.After you have added a virtual switch, you can set switch attributes (Setting Switch Attributes with esxcli network vswitch standard) and add one or more uplink adapters (Linking and Unlinking Uplink Adapters with ESXCLI).You cannot delete a virtual switch if any ports on the switch are still in use by VMkernel networks or virtual machines. Run esxcli network vswitch standard list to determine whether a virtual switch is in use.You can add and delete virtual switches using the --add|-a and --delete|-d options. Specify one of the options listed in Connection Options in place of <conn_options>.vicfg-vswitch <conn_options> - -add vSwitch2After you have added a virtual switch, you can set switch attributes (Setting Switch Attributes with vicfg-vswitch) and add one or more uplink adapters (Linking and Unlinking Uplink Adapters with vicfg-vswitch).You cannot delete a virtual switch if any ports on the switch are still in use by VMkernel networks, virtual machines, or vswifs. Run vicfg-vswitch --list to determine whether a virtual switch is in use.You can set the maximum transmission unit (MTU) and CDP status for a virtual switch. The CDP status shows which Cisco switch port is connected to which uplink. Specify one of the options listed in Connection Options in place of <conn_options>.The MTU is the size, in bytes, of the largest protocol data unit the switch can process. When you set this option, it affects all uplinks assigned to the virtual switch.
■ esxcli <conn_options> network vswitch standard set --cdp-status=listen --vswitch-name=vSwitch1You can set the maximum transmission unit (MTU) and CDP status for a virtual switch. The CDP status shows which Cisco switch port is connected to which uplink. Specify one of the options listed in Connection Options in place of <conn_options>.The MTU is the size (in bytes) of the largest protocol data unit the switch can process. When you set this option, it affects all uplinks assigned to the virtual switch.
■ Network services connect to vSwitches through port groups. A port group allows you to group traffic and specify configuration options such as bandwidth limitations and VLAN tagging policies for each port in the port group. A virtual switch must have one port group assigned to it. You can assign additional port groups.You can use esxcli network vswitch standard portgroup to check, add, and remove port groups. Specify one of the options listed in Connection Options in place of <conn_options>.esxcli <conn_options> network vswitch standard portgroup add --portgroup-name=<name> --vswitch-name=vSwitch1esxcli <conn_options> network vswitch standard portgroup remove --portgroup-name=<name> --vswitch-name=vSwitch1Network services connect to virtual switches through port groups. A port group allows you to group traffic and specify configuration options such as bandwidth limitations and VLAN tagging policies for each port in the port group. A virtual switch must have one port group assigned to it. You can assign additional port groups. Specify one of the options listed in Connection Options in place of <conn_options>.You can use vicfg-vswitch to check, add, and remove port groups.vicfg-vswitch <conn_options> - -check-pg <port_group> vSwitch1The command returns 0 if the specified port group is associated with the virtual switch, and returns 1 otherwise. Use vicfg-vswitch --list to list all port groups.You can manage uplinks and port groups with ESXCLI and with vicfg-vswitch.If your setup includes one or more port groups, you can associate each port group with one or more uplink adapters (and remove the association). This functionality allows you to filter traffic from a port group to a specific uplink, even if the virtual switch is connected with multiple uplinks. Specify one of the options listed in Connection Options in place of <conn_options>.esxcli <conn_options> network vswitch standard portgroup policy failover set --active-uplinks=vmnic1,vmnic6,vmnic7esxcli <conn_options> network vswitch standard portgroup policy failover set --standby-uplinks=vmnic1,vmnic6,vmnic7If your setup includes one or more port groups, you can associate each port group with one or more uplink adapters (and remove the association). This functionality allows you to filter traffic from a port group to a specific uplink, even if the virtual switch is connected with multiple uplinks. Specify one of the options listed in Connection Options in place of <conn_options>.vicfg-vswitch <conn_options> - -add-pg-uplink <adapter_name> - -pg <port_group> <vswitch_name>You can set the port group VLAN ID with ESXCLI and with vicfg-vswitch.VLANs allow you to further segment a single physical LAN segment so that groups of ports are isolated as if they were on physically different segments. The standard is IEEE 802.1Q.If you use VLAN IDs, you must change the port group labels and VLAN IDs together so that the labels properly represent connectivity. VLAN IDs are optional.VLANs allow you to further segment a single physical LAN segment so that groups of ports are isolated as if they were on physically different segments. The standard is IEEE 802.1Q.If you use VLAN IDs, you must change the port group labels and VLAN IDs together so that the labels properly represent connectivity. VLAN IDs are optional.Run vicfg-vswitch -l to retrieve information about VLAN IDs currently associated with the virtual switches in the network.Run esxcli network vswitch standard portgroup list to list all port groups and associated VLAN IDs.You can manage uplink adapters, which represent the physical NICs that connect the ESXi host to the network by using the esxcli network nics or the vicfg-nics command. You can also use esxcli network vswitch and esxcfg-vswitch to link and unlink the uplink.You can use vicfg-nics to list information and to specify speed and duplex setting for the uplink.You can use esxcli network nic to list all uplinks, to list information, to set attributes, and to bring a specified uplink down or up.The following example workflow lists all uplink adapters, lists properties for one uplink adapter, changes the uplink’s speed and duplex settings, and brings the uplink down and back up. Specify one of the options listed in Connection Options in place of <conn_options>.
Name of the NIC to configured. Must be one of the cards listed in the nic list command (required).
■ aui – Select aui as the device port
■ bnc – Select bnc as the device port
■ fibre – Select mii as the device port
■ mii – Select mii as the device port
■ tp – Select tp as the device port
■ external – Set the transceiver type to external
■ internal – Set the transceiver type to internal Set Wake-on-LAN options. Not all devices support this option. The option value is a string of characters specifying which options to enable.
■ p – Wake on phy activity
■ u – Wake on unicast messages
■ m – Wake on multicast messages
■ b – Wake on broadcast messages
■ a – Wake on ARP
■ g – Wake on MagicPacket
■ s – Enable SecureOn password for MagicPacketAt any time, one port group NIC array and a corresponding set of active uplinks exist. When you change the active uplinks, you also change the standby uplinks and the number of active uplinks.
1 The portgroup nic array is [vmnic1, vmnic0, vmnic3, vmnic5, vmnic6, vmnic7] and active-uplinks is set to three uplinks (vmnic1, vmnic0, vmnic3). The other uplinks are standby uplinks.
2
3 The new uplinks override the old set. The NIC array changes to [vmnic3, vmnic5, vmnic6, vmnic7]. vmnic0 and vmnic1 are removed from the NIC array and max-active becomes 2.If you want to keep vmnic0 and vmnic1 in the array, you can make those NICs standby uplinks in the command that changes the active uplinks.esxcli network vswitch standard portgroup policy failover set -p testPortgroup --active-uplinks vmnic3,vmnic5 --standby-uplinks vmnic1,vmnic0,vmnic6,vmnic7The following example workflow lists an uplink adapter’s properties, changes the duplex and speed, and sets the uplink to autonegotiate its speed and duplex settings. Specify one of the options listed in Connection Options in place of <conn_options>.
2
3 Set vmnic2 to autonegotiate its speed and duplex settings.When you create a virtual switch using esxcli network vswitch standard add, all traffic on that virtual switch is initially confined to that virtual switch. All virtual machines connected to the virtual switch can talk to each other, but the virtual machines cannot connect to the network or to virtual machines on other hosts. A virtual machine also cannot connect to virtual machines connected to a different virtual switch on the same host.Having a virtual switch that is not connected to the network might make sense if you want a group of virtual machines to be able to communicate with each other, but not with other hosts or with virtual machines on other hosts. In most cases, you set up the virtual switch to transfer data to external networks by attaching one or more uplink adapters to the virtual switch.You can use the following commands to list, add, and remove uplink adapters. When you link using ESXCLI, the physical NIC is added as a standby adapter by default. You can then modify the teaming policy to make the physical NIC active by running the command esxcli network vswitch standard policy failover set.The uplink adapters are returned in the Uplink item.esxcli <conn_options> network vswitch standard uplink add --uplink-name=vmnic15 vswitch-name=vSwitch0esxcli <conn_options> network vswitch standard uplink remove --uplink-name=vmnic15 vswitch-name=vSwitch0When you create a virtual switch using vicfg-vswitch --add, all traffic on that virtual switch is initially confined to that virtual switch. All virtual machines connected to the virtual switch can talk to each other, but the virtual machines cannot connect to the network or to virtual machines on other hosts. A virtual machine also cannot connect to virtual machines connected to a different virtual switch on the same host.Having a virtual switch that is not connected to the network might make sense if you want a group of virtual machines to be able to communicate with each other, but not with other hosts or with virtual machines on other hosts. In most cases, you set up the virtual switch to transfer data to external networks by attaching one or more uplink adapters to the virtual switch.VMkernel network interfaces are used primarily for management traffic, which can include vMotion, IP Storage, and other management traffic on the ESXi system. You can also bind a newly created VMkernel network interface for use by software and dependent hardware iSCSI by using the esxcli iscsi commands.The VMkernel network interface is separate from the virtual machine network. The guest operating system and application programs communicate with a VMkernel network interface through a commonly available device driver or a VMware device driver optimized for the virtual environment. In either case, communication in the guest operating system occurs as it would with a physical device. Virtual machines can also communicate with a VMkernel network interface if both use the same virtual switch.Each VMkernel network interface has its own MAC address and one or more IP addresses, and responds to the standard Ethernet protocol as would a physical NIC. The VMkernel network interface is created with TCP Segmentation Offload (TSO) enabled.You can manage VMkernel NICs with ESXCLI (see Managing VMkernel Network Interfaces with ESXCLI) and with vicfg-vmknic (see Managing VMkernel Network Interfaces with vicfg-vmknic).You can configure the VMkernel network interface for IPv4 (see To add and configure an IPv4 VMkernel Network Interface for IPv4) or for IPv6 (see To add and configure a VMkernel Network Interface for IPv6) with ESXCLI. In contrast to vicfg-vmknic, ESXCLI does not support enabling vMotion.You can add and configure an IPv4 VMkernel NIC with ESXCLI. Specify one of the options listed in Connection Options in place of <conn_options>.esxcli <conn_options> network ip interface add --interface-name=vmk<x> --portgroup-name=<my_portgroup>You can specify the MTU setting after you have added the network interface by using esxcli network ip interface set --mtu.
2 Configure the interface as an IPv4 interface. You must specify the IP address using - -ip, the netmask, and the name. For the following examples, assume that VMSF-VMK-363 is a port group to which you want to add a VMkernel network interface.esxcli <conn_options> network ip interface ipv4 set - -ip=<ip_address> --netmask=255.255.255.0 --interface-name=vmk<X>
■ <X.X.X.X>– Static IPv4 address.
■ DHCP – Use IPv4 DHCP.The command displays the network information, port group, MTU, and current state for each virtual network adapter in the system.
1 Run esxcli network ip interface add to add a new VMkernel network interface.esxcli <conn_options> network ip interface add --interface-name=vmk<x> --portgroup-name=<my_portgroup>You can specify the MTU setting after you have added the network interface by using esxcli network ip interface set --mtu.
2 Run esxcli network ip interface ipv6 address add to configure the interface as an IPv6 interface. You must specify the IP address using - -ip and the name. For the following examples, assume that VMSF-VMK-363 is a port group to which you want to add a VMkernel network interface.esxcli <conn_options> network ip interface ipv6 address add - -ip=<X:X:X::/X> --interface-name=vmk<X>
■ --enable-dhcpv6: Enables DHCPv6 on this interface and attempts to acquire an IPv6 address from the network.
■ --enable-router-adv: Use the IPv6 address advertised by the router. The address is added when the router sends the next router advert.The list contains the network information, port group, MTU, and current state for each VMkernel Network Interface on the system.esxcli <conn_options> network ip interface ipv6 address remove --interface-name=<VMK_NIC> --ipv6=<ipv6_addr>You can configure the VMkernel network interface for IPv4 (see To add and configure an IPv4 VMkernel Network Interface with vicfg-vmknic) or for IPv6 (see To add and configure an IPv6 VMkernel Network Interface with vicfg-vmknic). Specify one of the options listed in Connection Options in place of <conn_options>.
1 Run vicfg-vmknic --add to add a VMkernel network interface.You must specify the IP address by using - -ip, the netmask, and the name. For the following examples, assume that VMSF-VMK-363 is a port group to which you want to add a VMkernel network interface.vicfg-vmknic <conn_options> --add - -ip <ip_address> -n 255.255.255.0 VMSF-VMK-363You can specify the MTU setting when adding a VMkernel network interface. You cannot change that setting at a later time.
■ <X.X.X.X>– Static IPv4 address.
■ DHCP – Use IPv4 DHCP.You can later use --disable-vmotion to disable vMotion for this VMkernel network interface.The command displays the network information, port group, MTU, and current state for each virtual network adapter in the system.
1 Run vicfg-vmknic --add to add a VMkernel network interface.You must specify the IP address by using - -ip, the netmask, and the port group name. For the following examples, assume that VMSF-VMK-363 is a port group to which you want to add a VMkernel network interface.You can specify the MTU setting when you add a VMkernel network interface. You cannot change that setting at a later time.vicfg-vmknic <conn_options> - -ip <ip_address> VMSF-VMK-363
■ <X:X:X::/X> – Static IPv6 address
■ DHCPV6 – Use DHCP IPv6 address. The VMkernel supports DHCP only for ESX/ESXi 4.0 and later.
■ AUTOCONF – Use the IPv6 address advertised by the router. If you create a VMkernel network interface with AUTOCONF, an address is assigned immediately. If you add AUTOCONF to an existing vmknic, the address is added when the router sends the next router advert.You can later use --disable-vmotion to disable vMotion again.