Add a physical NIC to a vSwitch using the command line or cli

Just a quick tip for vmware ESX. If you delete by mistake, or just need to add a vmnic to a vSwitch, and you do not have access to the ESX host using the GUI client all hope is not lost. You can still do this using the command line interface (or cli for short). To do so log into the ESX host as root, in my case I had to gain access to the console using the DRAC. Once logged in issue the following command:
esxcfg-vswitch -l
This will list info about ALL of the vSwitches on this ESX host. Find the name of the switch you need to add this NIC to. In my case I need to add vmnic1 to vSwitch0. I accidently deleted it. To readd this NIC I will issue the following command:
esxcfg-vswitch -L vmnic1 vSwitch0
I can verify this worked by using the -l switch again and I will see that the vSwitch0 now has vmnic1 in the list of uplinks.

Leave a Reply

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