VMware Cloud Community
Beav
Contributor
Contributor

Networking Commands for Virtual Machines

Is there a command to add another nic to a virtual machine and/or a script?

0 Kudos
7 Replies
mittim12
Immortal
Immortal

You could use the powercli cmdlet of new-networkadapter.






If you found this or any other post helpful please consider the use of the Helpful/Correct buttons to award points

Beav
Contributor
Contributor

Thanks for the re-ply, I will try that, I was not sure if there is a command in which I could run from the Service Console to add a NIC. I could not find any. If anyone knows of a command to use on the CLI will be helpful.

Thanks,

-Beav

0 Kudos
gary1012
Expert
Expert

VIM shell might be an option...

/usr/bin/vmware-vim-cmd vmsvc/getallvms (note the VM #)

/usr/bin/vmware-vim-cmd vmsvc/devices.createnic (VM #)

A vimsh reference can be found at this link.

Community Supported, Community Rewarded - Please consider marking questions answered and awarding points to the correct post. It helps us all.

Community Supported, Community Rewarded - Please consider marking questions answered and awarding points to the correct post. It helps us all.
Beav
Contributor
Contributor

This is helpful and works, however when it adds the nic it mentions:

This host does not have any virtual machine networks, or you don't have permission to access them. I did the command through root and it has a Virtual Machine Network. Which is weird because I told it to use the VMware network with the command.

Command - vmware-vim-cmd vmsvc/devices.createnic 112 0 e1000 VM Network

It requires the following: vmid unit number type network

Is the unit and number the same question or different and if so, what is the "unit number" and if separate, what is the "unit" and what is the "number"?

I am close, it adds the NI, but have this little issue.

Thanks,

-Beav

0 Kudos
gary1012
Expert
Expert

OK, you'll laugh but I've never actually tried to add a NIC via vimsh. I used vimsh for other operations and knew you could perform VM changes. As for the actual syntax options on this operation, I'm out cold too. As for network port groups, you may have to use quotes since there is a space in the name. How about posting the answer if you get it to work.

If you need to create port groups or have a requirement to script changes to vSwitches; you could use either esxcfg cmds or vimsh with the hostsvc/net options.

Community Supported, Community Rewarded - Please consider marking questions answered and awarding points to the correct post. It helps us all.

Community Supported, Community Rewarded - Please consider marking questions answered and awarding points to the correct post. It helps us all.
0 Kudos
Beav
Contributor
Contributor

This was very helpful and almost works I have tied differnt commands to add a NIC, it adds it to the Virtual Machine, but even though I assign it to a Network, when I look at the properties of the NIC I just added it has an error:

"This Host does not have any virtual machine networks, or you dont have the permission to access them"

It then tells me to make sure I have a VM network (which I do, even created a 2nd one).

Here is the command I issued - vmware-vim-cmd vmsvc/devices.createnic 112 9 e1000 "VM"

(Command) VMID| Unit# | type |Network

Thanks,

-Beav

0 Kudos
joeyt
Contributor
Contributor

Beav,

I know this is an old post, but I'm seeing the exact same issue. Were you ever able to find a solution?

Thanks!

0 Kudos