VMware Cloud Community
LuckyT
Contributor
Contributor

Assign multiple IP's to VM using Guest Customization Script

Hi All,

How to assign multiple IP's to a VM using Guest Customization Script. I have a script which assigns single IP, but my requirement is to assign another IP to a VM. Guest OS is Linux/Windows. Kindly post sample workflows..

Thanks in advance

0 Kudos
6 Replies
tschoergez
Leadership
Leadership

Hi,

AFAIK assigning multiple IPs to a VM via Guest Customization only works if the VM has multiple virtual network cards. The Guest Customization only supports assigning one IP per network card.

It's the CustomizationFixedIP you assign to the .ip attribute of the .adapter attribute of the .nicSettingsMap attribute of the customizationSpecification. And that .nicSettingsMap is an array, on entry for each virtual nic in the VM.

The number of elements in this array has to match exactly the number of nics in the VM, otherwise you will get an error from vCenter. See the API reference for details.

I recommend to assign the second IP afterwards (if you want to have multiple IPs for a single nic), using the SSH Plugin or the Guest Script manager package Guest script manager package to edit the config files in /etc/network (or whereever).

Cheers,

Joerg

0 Kudos
LuckyT
Contributor
Contributor

I won't assign multiple IP to single Nic. I will create multiple Nics & assign the IP respectively.

However, I'm not able to use guest script manager package, for which i'm following in another discussion.

0 Kudos
tschoergez
Leadership
Leadership

ok, then check these to see an example how to use the customizationSpec:

customizationSpec

http://www.vcoportal.de/2011/04/customize-a-virtual-machine/

For multiple nics you just repeat the whole creation of

  1. var myVcCustomizationAdapterMapping = new VcCustomizationAdapterMapping() ; 

for each nic, and add it to the adapter mapping array.


Cheers,

Joerg

0 Kudos
LuckyT
Contributor
Contributor

Thanks.

0 Kudos
LuckyT
Contributor
Contributor

Hi,

Is it possible to assign IP to only one NIC out of Two NICs available while customization?

Thanks in advance.

0 Kudos
tschoergez
Leadership
Leadership

no. you have to specify two VcCustomizationAdapterMappings if the VM has two nics.

Two possible workarounds: Configure the second card to use DHCP in the customizationSpec, or use a source VM with only one NIC and add the second NIC later via a different workflow.

Cheers,

Joerg

0 Kudos