Configure and View vSS and vDS Settings Using Command Line Tools

by admin

There are a number of command line tools you can use to view and configure virtual switch settings. To start with there are the following esxcfg-/vicfg- commands:

  • esxcfg-vswitch – Used to configure virtual switches
  • esxcfg-nics– Used to configure physical NICs
  • esxcfg-vmknic – Used to configure VMkernel ports
  • esxcfg-route – Used to configure host routing.

In addition to these commands, there are also the ESXCLI network commands:

~ # esxcli network
Usage: esxcli network {cmd} [cmd options]

Available Namespaces:
  fence                 Commands to list fence information
  firewall              A set of commands for firewall related operations
  ip                    Operations that can be performed on vmknics
  nic                   Operations having to do with the configuration of Network Interface Card and getting and updating the NIC settings.
  port                  Commands to get information about a port
  sriovnic              Operations having to do with the configuration of SRIOV enabled Network Interface Card and getting and updating the NIC settings.
  vm                    A set of commands for VM related operations
  vswitch               Commands to list and manipulate Virtual Switches on an ESX host.
  diag                  Operations pertaining to network diagnostics

All of these commands offer a lot of options, so the rest of this post will look at some of the more common tasks you can do with them, with a focus on the ESXCLI commands, rather than the legacy esxcfg-* scripts.

Configuring ESXi Physical NICs Using Command Line Tools

To view the physical network adapters installed in a host, and their configuration, you can run:

~ # esxcli network nic list
Name    PCI Device     Driver  Link  Speed  Duplex  MAC Address         MTU  Description                                                   
------  -------------  ------  ----  -----  ------  -----------------  ----  --------------------------------------------------------------
vmnic0  0000:002:00.0  e1000   Up     1000  Full    00:0c:29:3c:c3:4e  1500  Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic1  0000:002:01.0  e1000   Up     1000  Full    00:0c:29:3c:c3:58  1500  Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic2  0000:002:02.0  e1000   Up     1000  Full    00:0c:29:3c:c3:62  1500  Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic3  0000:002:03.0  e1000   Up     1000  Full    00:0c:29:3c:c3:6c  1500  Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic4  0000:002:05.0  e1000   Up     1000  Full    00:50:56:af:19:ad  1500  Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic5  0000:002:06.0  e1000   Up     1000  Full    00:50:56:af:1e:0a  1500  Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic6  0000:002:07.0  e1000   Up     1000  Full    00:50:56:af:47:88  1500  Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic7  0000:002:08.0  e1000   Up     1000  Full    00:50:56:af:4f:80  1500  Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)

You can get further detail on individual NICs by running:

~ # esxcli network nic get -n vmnic1
   Advertised Auto Negotiation: true
   Advertised Link Modes: 10baseT/Half, 10baseT/Full, 100baseT/Half, 100baseT/Full, 1000baseT/Full
   Auto Negotiation: true
   Cable Type: Twisted Pair
   Current Message Level: 7
   Driver Info: 
         Bus Info: 0000:02:01.0
         Driver: e1000
         Firmware Version: N/A
         Version: 8.0.3.1-NAPI
   Link Detected: true
   Link Status: Up 
   Name: vmnic1
   PHYAddress: 1
   Pause Autonegotiate: true
   Pause RX: false
   Pause TX: false
   Supported Ports: TP
   Supports Auto Negotiation: true
   Supports Pause: true
   Supports Wakeon: false
   Transceiver: internal
   Wakeon: None

You can use ‘set’ commands to change settings on the NIC. For example, to change the speed and duplex settings, you could run:

~ # esxcli network nic set --duplex=full --speed=1000 -n vmnic1

Useful for troubleshooting purposes, you can view statistics for a given NIC by running:

~ # esxcli network nic stats get -n vmnic1
NIC statistics for vmnic1
   Packets received: 228216
   Packets sent: 7794
   Bytes received: 279836337
   Bytes sent: 980658
   Receive packets dropped: 0
   Transmit packets dropped: 0
   Total receive errors: 0
   Receive length errors: 0
   Receive over errors: 0
   Receive CRC errors: 0
   Receive frame errors: 0
   Receive FIFO errors: 0
   Receive missed errors: 0
   Total transmit errors: 0
   Transmit aborted errors: 0
   Transmit carrier errors: 0
   Transmit FIFO errors: 0
   Transmit heartbeat errors: 0
   Transmit window errors: 0

Configuring vSwitches Using Command Line Tools

Command line functionality for dvSwitches is limited, however you can view the dvSwitches configured on a host by running:

~ # esxcli network vswitch dvs vmware list
dvSwitch
   Name: dvSwitch
   VDS ID: 21 f1 2f 50 0b c2 7c 0b-50 d8 9b 26 12 ef e2 e2
   Class: etherswitch
   Num Ports: 256
   Used Ports: 5
   Configured Ports: 256
   MTU: 1500
   CDP Status: listen
   Beacon Timeout: -1
   Uplinks: vmnic7, vmnic6
   VMware Branded: true
   DVPort: 
         Client: vmnic6
         DVPortgroup ID: dvportgroup-662
         In Use: true
         Port ID: 258

         Client: vmnic7
         DVPortgroup ID: dvportgroup-662
         In Use: true
         Port ID: 259

To list the standard vSwitches configured on a host:

~ # esxcli network vswitch standard list
vSwitch0
   Name: vSwitch0
   Class: etherswitch
   Num Ports: 128
   Used Ports: 7
   Configured Ports: 128
   MTU: 1500
   CDP Status: listen
   Beacon Enabled: false
   Beacon Interval: 1
   Beacon Threshold: 3
   Beacon Required By: 
   Uplinks: vmnic2, vmnic0
   Portgroups: vMotion, Management Network

To create a new standard vSwitch you can run:

~ # esxcli network vswitch standard add -v vSwitch9

There are a number of sub-namespaces available for running commands against standard vSwitches:

~ # esxcli network vswitch standard 
Usage: esxcli network vswitch standard {cmd} [cmd options]

Available Namespaces:
  policy                Commands to manipulate network policy settings governing the given virtual switch.
  portgroup             Commands to list and manipulate Port Groups on an ESX host.
  uplink                Commands to add and remove uplink on given virtual switch.

These are used to attach uplinks to the vSwitch, create/remove portgroups and set policies. For example, you can run the following to list the security settings for a given portgroup:

~ # esxcli network vswitch standard portgroup policy security get -p vMotion
   Allow Promiscuous: false
   Allow MAC Address Change: true
   Allow Forged Transmits: true
   Override Vswitch Allow Promiscuous: false
   Override Vswitch Allow MAC Address Change: false
   Override Vswitch Allow Forged Transmits: false

Configuring Virtual Adapters Using Command Line Tools

You can list VMkernel interfaces with the following command:

~ # esxcli network ip interface list
vmk0
   Name: vmk0
   MAC Address: 00:0c:29:3c:c3:4e
   Enabled: true
   Portset: vSwitch0
   Portgroup: Management Network
   VDS Name: N/A
   VDS UUID: N/A
   VDS Port: N/A
   VDS Connection: -1
   MTU: 1500
   TSO MSS: 65535
   Port ID: 33554438

You can also use the ‘esxcli network ip interface’ namespace to create virtual adapters and assign them to port groups. For example, the following is to create two adapters for use with iSCSI, along with assigning them to portgroups:

~ # esxcli network ip interface add -p ISCSI_1 -i vmk1
~ # esxcli network ip interface add -p ISCSI_2 -i vmk3
~ # esxcli network ip interface ipv4 set -i vmk1 -I 10.10.0.10 -N 255.255.255.0 -t static
~ # esxcli network ip interface ipv4 set -i vmk3 -I 10.10.0.12 -N 255.255.255.0 -t static

Configuring ESXi Routing using Command Line Tools

You can list the routing table on a host by running:

~ # esxcli network ip route ipv4 list
Network      Netmask        Gateway        Interface  Source
-----------  -------------  -------------  ---------  ------
default      0.0.0.0        192.168.0.239  vmk0       MANUAL
10.10.0.0    255.255.255.0  0.0.0.0        vmk1       MANUAL
172.16.0.0   255.255.255.0  0.0.0.0        vmk2       MANUAL
192.168.0.0  255.255.255.0  0.0.0.0        vmk0       MANUAL

You can add/remove additional routes. For example:

~ # esxcli network ip route ipv4 add -n 184.45.34.0/24 -g 192.168.0.1

Keep up to date with new posts on Buildvirtual.net - Follow us on Twitter:
Be Sociable, Share!

Comments on this entry are closed.

Previous post:

Next post: