Total loss of ESXi Management Network Settings – rebuild vSwitch, portgroup and IP settings with command line

The following scenario occurred during the migration of an ESXi 4.1 Host to a new vSphere 5 Cluster:

An ESXi 4.1 host with appoximately 30 running, high productive virtual machines should be migrated to a new vSphere 5 cluster. As part of this change a distributed switch used in the old vSphere 4.1 cluster was removed from the host. Thereby the host lost all the settings for the Management Network.

Fortunately the virtual machines were still running and reachable over the network.

The only possibility to manage the host was the Console.

There we saw the possibility to “Reset Management Network to factory defaults”.

As we were not sure if this would affect the functional network used by the virtual machines we did not consider this possibility.

Solution:

Per commandline we created a new vSwitch. Then a dedicated pNIC (vmnic0) was added to the new vSwitch and a portgroup (Management Network), too.
The last step was to set the IP address/Subnet.

After a reconnect from the host in vCenter everything was fine!

Used Commands:

• esxcfg-vswitch -a vSwitch1
With this command you can create a new vSwitch named: “vSwitch1”

• esxcfg-vswitch -A “Management Network” vSwitch1
now you can assign a portgroup “Management Network” to the new vSwitch1

• esxcfg-vswitch -L vmnic0 vSwitch1
this step adds pNIC “vmnic0” to the vSwitch1

• esxcfg-vmknic -a “Management Network” -i 160.xxx.xxx.xxx -n 255.xxx.xxx.xxx
this command will set the IP address/Subnet

If necessary you can use the parameter -l (for list) to show the current configuration!

Results (using esxcfg-vswitch -l):

And in the vCenter:

1 Comment

  1. anonymous

    Thanks, my dvsdata.db was corrupted and management network was in DVS. the esxi host was completely not rechable. also I couldn’t able to create vswitch using esxcli network *.. commands.
    By following you steps i restored network back

Leave a Comment

Your email address will not be published. Required fields are marked *