At this little article writes about what can do Virtualization(VMware) Admins when they docent have access to GUI configuration or in the worse situations, when ESXI Network can't work properly, for example you have one NIC for Management a ESXI Server and cause any unexpected failure, NIC can't up and VSPhere web client is unreachable, and when VCenter want to control and solve this problem, Operation see an BIG-Error about Management connection to the ESXI Server xxxx lost. Maybe first think any sysadmin can do it is change the Physical NIC assigned to Management PortGroup and everything can work properly again like before fault, but when ESXI joined to a VCenter and All of other physical ports assigned to VDS Switches as a UP-Link we can't get them back in the console and assign them to the any other switch or any management change to them. In fact it is a one of situation can be occurring and sysadmins need to configure ESXI network from shell, command-line, console.
If anyone have this situation and he/she don't know how to manage ESXI network via console, then he/she must reinstall ESXI, restore backup and so many other solution they need to restart host or change OS reconfigure it and in the end we have so many wast time.
In this little Article we try to show you how to configure ESXI Networking VSwitch via console and how to use [ esxcfg-vswitch ] command.
First, for you get access to your ESXI-Shell press ALT+F1 to prompt user and password, input a user like root user and confirm to access shell.
In the next step we need to see how is the Networking map, use the [esxcfg-vswitch -l] to view V-Switches configuration and diagram in the text mode, in my lab I have one ESXI and two UP-Link or physical link and I have this output:
Switch Name: vSwitch0(Default name of ESXI first standard vSwitch ) , in this situation we haven't VCenter and we don't see any other switches like Distributed Switches or any other standard vSwitch, if we created standard switch in the ESXI Networking, there name was here.
Ok, and the next field is 'Num Ports' its default switch port number its 2560, in the maximum standard switches port number in a host is 4096 and 1016 Active port.
used port from 128 port is 6. And some other info like MTU and Important section for this troubleshooting is Uplink section and we have two NIC "vmnic0 , vmnic1 ".ESXI Management network need one of this physical port to work properly.
In the next step we need to delete vmnic0 from vSwitch0:
esxcfg-vswitch -U vmnic0 vSwitch0
Now ESXI have only one vmnic1 as a Active Up-Link.
create another vSwitch , of course if you have Management network in the another Vswitch and it is a Standard vSwitch, you don't need create another vSwitch and scape this step :
esxcfg-vswith -a [VSwitchName]
(for example in this lab environment I create a vSwitch mng_svsw)
in the next step to access Management network or ping successfully Management IP address, we need to link vmnic0 to Which switch name that exist for management purpose:
esxcfg-vswitch -L vmnic0 mng_svsw
at the last step we assign vmnic0 to Switch mng_svsw as a Up-Link.
The Uplink added successfully, just if you have vLan configuration on your switches you can set vLan on the new switch and PortGroup:
esxcfg-vswitch [switchName] -v [VLan Number] -p [PortGroupName]
esxcfg-vswitch mng_svsw -v 200 -p Management
VLAN ID is 0.
After VLAN Assignment:
VLAN ID is 200 and if your physical port on the ethernet switch is in the VLAN 200, now you must can Ping or can connect to it.
Set esxcfg-vswitch [Switchname] -m [MTU] #set MTU for Switch for example enable Jumbo Frame and set 9000 Byte.
esxcfg-vswitch have some other parameter can be useful to have better troubleshoot, like:
esxcfg-vswitch -c [SwitchName] #Check switch sexist or not
esxcfg-vswitch -C [PortGroupName] #Check PortGroup exist or not