VMware Cloud Community
mvsiva
Contributor
Contributor

How to add the VM virtual network interface to vSwitch thru CLI?

I have ESXI hypervisor installed and running 4 VMs.  I want to create a specific topology between these 4 VMs. So I need to create virutal swith and add the virtual network interface of these VMs  to these virtual switch.  I am planning to automate this and hence I'm using the VMware vSphere CLI command line interface. But I am not able to find the CLI command for adding the virtual network interface to vSwitch. Does it only support adding physical interface?

I am able to do the same through the vSphere client UI.

0 Kudos
4 Replies
AnthonyChow
Hot Shot
Hot Shot

esxcfg-vmknic –a –i 192.168.28.105 –n 255.255.255.0 PortGroupName

Also, will this help:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=100025...

This site has a whole bunch of script:

http://www.virtuallyghetto.com/

0 Kudos
mvsiva
Contributor
Contributor

Thanks for your reply.

My query was how to Link a virtual Network interface of a VM to a vswitch. Is there a option to provide the virtual network interface in the below command?

vicfg-vswitch <conn_options> -L <physical adapter name> <vswitch name>

Lets say that I have ESXI server with 2 VMs - VM1 & VM2. I want to connect the VM1's virtual network interface eth1 with VM2's virtual network interface eth1 through CLI.

I can do this connection with VSphere client UI like this - I will go to the VM1 machine's eth1 and give the network label as vswitch1. Similarly I can do the same for VM2 machines eth1.  I want an equivalent CLI command to do this.

Can someone help me to do this?

0 Kudos
AnthonyChow
Hot Shot
Hot Shot

0 Kudos
AnthonyChow
Hot Shot
Hot Shot

I found this example in Scott Lowe's book.

vicfg-vswitch –A VLAN31-Finance vSwitch2 --vihost esx01.vmwarelab.net

Will this work for you?

0 Kudos