Some useful esxcli network commands

Reading Time: 7 minutes

Some useful esxcli network commands is an article that shows some useful esxcli network commands that help the administrator in day-to-day life.

So, before we start, I would like to share a command reference (guide) related to the ESXi command. In this guide, we can find a lot of esxcli commands, syntax, etc:
https://developer.vmware.com/docs/11743/esxi-7-0-esxcli-command-reference

Firstly, the list of commands that we will talk about. So, to jump to a specific command, click on the link through the name of the command:

esxcli network nic list
esxcli network nic down
esxcli network nic up

esxcli network nic get
esxcli network nic set
esxcli network nic stats get
esxcli network ip interface ipv4 get
esxcli network ip interface ipv4 set
esxcli network ip interface tag get
esxcli network ip interface tag add
esxcli network ip interface tag remove

esxcli network ip neighbor list
esxcli network ip route ipv4 list
esxcli network ip route ipv4 add
esxcli network ip route ipv4 remove

esxcli network ip connection list
esxcli network vswitch standard list
esxcli network vswitch dvs vmware list

esxcli network nic list (command list)

The command “esxcli network nic list” will list the existing physical network interface on the ESXi host.
Besides that, this command will show:

  • The nic names such as vmnic0, vmnic1, etc
  • The PCI device address
  • What driver the nic is using
  • Admin and Link status such as Up or Down
  • Speed and Duplex details
  • MAC Address
  • MTU
  • Also, a description of the nic interface

Note: During a troubleshooting step, these details are very important to understand what happens with the ESXi host related to network vision.

esxcli network nic down (command list)

The command “esxcli network nic down -n <NIC_NAME>” can be used to put a specific nic card into a DOWN state. For example, if we need to put the interface vmnic0 into a down state (for some test or administrative purpose), the command will be:

esxcli network nic down -n vmnic0

After applying the command, we can see that the vmnic0 interface went to “down” status, for example:

esxcli network nic up (command list)

The command “esxcli network nic up -n <NIC_NAME>” can be used to put a specific nic card into a UP state.
So, the syntax of this command will be:

esxcli network nic up -n vmnic0

In this example, vmnic0 is currently down. We applied the command, and now it is UP again. In the picture below, following the evidence:

esxcli network nic get (command list)

The command “esxcli network nic get -n <NIC_NAME>” can be used to show a lot of details about a specific nic card. With this command, for example, we can see the firmware version and other details as well. The syntax of this command is:

esxcli network nic get -n vmnic0

esxcli network nic set (command list)

The command “esxcli network nic set -n <NIC_NAME> <OPTIONS>” can be used to set or modify a lot of nic configurations. We can, for example, change the nic speed or change the nic duplex mode.
For example, for changing the nic speed and duplex mode, the syntax will be:

esxcli network nic set -n vmnic0 -S 100 -D full

Note: However, a lot of possibilities we have with this command. To see the command help, for example, we can type “esxcli network nic set” and press ENTER.
So, we will see all options available for this command likes shown in the below picture:

esxcli network nic stats get (command list)

The command “esxcli network nic stats get” shows physical interface statistics, such as:

  • Packets received
  • Packets sent
  • Bytes received
  • Bytes sent
  • Receive packets dropped
  • Transmit packets dropped
  • Receive CRC errors
  • Receive frame errors
  • Receive FIFO errors
  • Receive missed errors
  • Etc.

Syntax of usage, for example, to get statistics from the vmnic0 interface:

esxcli network nic stats get -n vmnic0

esxcli network ip interface ipv4 get (command list)

The command “esxcli network ip interface ipv4 get” can show layer 3 details about interfaces. With this command, we will see:

  • Interface names, such as vmk0, vmk1, etc
  • IPv4 Address
  • IPv4 Netmask
  • IPv4 Broadcast Address
  • Address Type such as Static or DHCP
  • IP Address of Default Gateway
  • Ando also, DHCP DNS (if used)

This is a very useful command to see the vmkernels IP address during a troubleshooting step or something like that. As a result, we have 3 interfaces (3 VMkernels): vmk0, vmk1, and vmk2:

esxcli network ip interface ipv4 set (command list)

The command “esxcli network ip interface ipv4 set” can set or change vmkernel interface properties or values. For example, to change the IPv4 Address of the vmk2 interface, the syntax that we will use can be:

esxcli network ip interface ipv4 set -i vmk2 -I 10.10.10.1 -N 255.255.255.0 -g 10.10.10.254 -t static

With this command, for example, we are changing the IP Address, IPv4 Netmask, and Gateway of the vmkernel interface vmk2.

In the picture below, following the evidence:

esxcli network ip interface tag get (command list)

The command “esxcli network ip interface tag get -i <vmkernel_name>” can be used to show what is the Tags or Services that are running on this specific vmkernel interface or what type of traffic this vmkernel interface is responsible for handling.

To get Tags for vmk0, for example, the command will be:

esxcli network ip interface tag get -t vmk0

Note: Additionally, we developed a script to get all Tags for all vmkernels present on the ESXi host:

for i in $(esxcli network ip interface ipv4 get | sed 1,2d | awk -F" " '{print $1}'); do echo $i $(esxcli network ip interface tag get -i $i); done;

esxcli network ip interface tag add (command list)

The commando “esxcli network ip interface tag add -i <vmkernel_name> -t <tag_name>” can be used to add Tags to a specific vmkernel interface.

To add the Tag “faultToleranceLogging” to the vmk0, for example, the command will be:

esxcli network ip interface tag add -i vmk0 -t faultToleranceLogging

Note: As a result, the tag “faultToleranceLogging” was added to the vmk0, and the tag “Management” was maintained too. Supported tags are:

  • Management
  • VMotion
  • faultToleranceLogging
  • vSphereReplication
  • vSphereReplicationNFC
  • vSphereProvisioning
  • vSAN
  • VSANWitness
  • vSphereBackupNFC
  • PrecisionTimeProtocol
  • VSANReplication

esxcli network ip interface tag remove (command list)

The command “esxcli network ip interface tag remove -i <vmkernel_name> -t <tag_name>” can be used to remove a specific tag for a vmkernel interface.

For example:

esxcli network ip interface tag remove -i vmk0 -t faultToleranceLogging

esxcli network ip neighbor list (command list)

The command “esxcli network ip neighbor list” can be used to list ARP table entries. For example:

esxcli network ip neighbor list

esxcli network ip route ipv4 list (command list)

The command “esxcli network ip route ipv4 list” can be used to show the host’s routing table. For example:

esxcli network ip route ipv4 list

esxcli network ip route ipv4 add (command list)

The command “esxcli network ip route ipv4 add” can be used to add new static route entries in the host’s routing table.

For example, if we need to add a static route to reach a remote network 10.10.10.0/24 through default gateway 192.168.200.1, the syntax of the command will be:

esxcli network ip route ipv4 add -n 10.10.10.0/24 -g 192.168.200.1

In the picture below, following the evidence:

esxcli network ip route ipv4 remove (command list)

The command “esxcli network ip route ipv4 remove” can be used to remove a specific route entry from the host’s routing table.

To remove the same static route created before, the syntax of the command will be:

esxcli network ip route ipv4 remove -n 10.10.10.0/24 -g 192.168.200.1

esxcli network ip connection list (command list)

The command “esxcli network ip connection list” can be used to show all TCP/IP active connections. With this command, for example, you can check if a specific service is running and opening the TCP/IP socket.

For example:

esxcli network ip connection list

esxcli network vswitch standard list (command list)

The command “esxcli network vswitch standard list” can be used to list details about the Standard vSwitch on the ESXi host. If you execute this command on the ESXi host and the result is nothing, probably you do not have any Standard Switch on this ESXi host.

For example:

esxcli network vswitch standard list

We can see the vSwitch Name and a lot of other details, such as following the below picture:

esxcli network vswitch dvs vmware list (command list)

The command “esxcli network vswitch dvs vmware list” shows details about the Distributed Switch.

For example:

esxcli network vswitch dvs vmware list | more

The output of this command can be extensive, so, in this case, our recommendation is to use the “| more” at the final of the command.

We can see the Distributed Switch Name, Uplink Interfaces, and all DVPort that are being used at the moment:

2 responses to “Some useful esxcli network commands”