How to configure the network on an ESXi host using the command line is an article that explains how to create a standard switch (VSS), a port group (PG), and a management vmkernel interface using the esxcli command.
Here, we have an ESXi host without any vmkernel interface. Consequently, we cannot access this ESXi using its management IP. The only way to access this host is by using the DCUI:
Under the above screen, press F2 to enable the DCUI access. In this case, we need to enable the “ESXi Shell”, as we can see in the picture below:
Press F1 or Alt+F1 to access the DCUI. Now, we have access to the ESXi command line and we can configure the management interface:
Creating a vSphere Standard Switch (VSS)
First and foremost, we can check if any standard switch exists here:
esxcli network vswitch standard list
Creating a standard switch “vSwitch0”:
esxcli network vswitch standard add --vswitch-name=vSwitch0
Creating a vSphere Port Group (PG)
So, now we can create the port group. If you want, you can list all available port groups using the following command:
esxcli network vswitch standard portgroup list
Creating both port groups called “Management Network” and “VM Network”:
esxcli network vswitch standard portgroup add --portgroup-name="Management Network" --vswitch-name="vSwitch0"
esxcli network vswitch standard portgroup add --portgroup-name="VM Network" --vswitch-name="vSwitch0"
If necessary, you can set up a VLAN ID for each port group.
To set up the VLAN ID 10 for the port group “VM Network”, for instance, the command is:
esxcli network vswitch standard portgroup set -p "VM Network" -v 10
Creating VMKernel Interface and Associating it to a Port Group
The next step here is to create the VMKernel interface and associate it with a specific port group.
Creating the VMkernel interface “vmk0” and associating it to the port group “Management Network”:
esxcli network ip interface add --interface-name=vmk0 --portgroup-name="Management Network"
Specifying the IP address configuration for the vmk0 interface. In this case, for instance, the IP address configuration is:
- IP address: 192.168.255.124
- Network Mask: 255.255.255.0
esxcli network ip interface ipv4 set --interface-name=vmk0 --ipv4=192.168.255.124 --netmask=255.255.255.0 --type=static
Assigning a Default Gateway
The last step is to define the default gateway. We can do that with the following command.
In our example, the default gateway IP address is “192.168.255.1”:
esxcli network ip route ipv4 add --gateway=192.168.255.1 --network=default
Assigning Uplink Interface to the Standard Switch
At this moment, our VMKernel interface is configured, but our standard switch does not have any uplink interface.
The first step here is to check all physical interfaces available (vmnic0):
esxcli network nic list
In our case, for instance, we have only one interface available:
[root@localhost:~] esxcli network nic list
Name PCI Device Driver Admin Status Link Status Speed Duplex MAC Address MTU Description
------ ------------ -------- ------------ ----------- ----- ------ ----------------- ---- -----------
vmnic0 0000:0b:00.0 nvmxnet3 Up Up 10000 Full 00:0c:29:94:9a:28 1500 VMware Inc. vmxnet3 Virtual Ethernet Controller
Assigning the vmnic0 to the standard switch “vSwitch0”:
esxcli network vswitch standard uplink add --uplink-name=vmnic0 --vswitch-name=vSwitch0
After that, our switch has one uplink, as we can see in the following command:
[root@localhost:~] esxcli network vswitch standard list
vSwitch0
Name: vSwitch0
Class: cswitch
Num Ports: 1590
Used Ports: 4
Configured Ports: 128
MTU: 1500
CDP Status: listen
Beacon Enabled: false
Beacon Interval: 1
Beacon Threshold: 3
Beacon Required By:
Uplinks: vmnic0
Portgroups: VM Network, Management Network
Testing the Network Connectivity
If our configuration is fine, we should be able to reach the network devices. We can test the network communication from the ESXi host to the default gateway.
In our case, the default gateway is 192.168.255.1:
vmkping 192.168.255.1
In our case, the communication is working fine:
[root@localhost:~] vmkping 192.168.255.1
PING 192.168.255.1 (192.168.255.1): 56 data bytes
64 bytes from 192.168.255.1: icmp_seq=0 ttl=128 time=0.936 ms
64 bytes from 192.168.255.1: icmp_seq=1 ttl=128 time=1.175 ms
64 bytes from 192.168.255.1: icmp_seq=2 ttl=128 time=0.502 ms
--- 192.168.255.1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.502/0.871/1.175 ms
Reference:
https://portal.nutanix.com/page/documents/kbs/details?targetId=kA032000000CifmCAC