samuelkeller
Contributor
Contributor

Assign a static IP address to newly deployed VMs

Jump to solution

Does anyone have any good way to deploy VMs from templates and asssign and configure a static IP address?

0 Kudos
1 Solution

Accepted Solutions
mrksiddiqui
Enthusiast
Enthusiast

Have you looked into Customization and Specification Manager? When used with deploying VM from templates, you can make it ask the user for static IP address.

If this helps answer your question please consider awarding points!

View solution in original post

0 Kudos
7 Replies
samuelkeller
Contributor
Contributor

Thank you in advance for your help!

0 Kudos
mrksiddiqui
Enthusiast
Enthusiast

Have you looked into Customization and Specification Manager? When used with deploying VM from templates, you can make it ask the user for static IP address.

If this helps answer your question please consider awarding points!

View solution in original post

0 Kudos
samuelkeller
Contributor
Contributor

I am currently using the custimization specifications for new deployments and it prompts for the IP; however, I am looking for an automated method of assigning IP addresses to new VMs.

0 Kudos
samuelkeller
Contributor
Contributor

In your screen shot there is an option that is greyed out called "Use an application configured on the vCenter Server to generate the IP address."  This is the type of solution that I am looking for.

0 Kudos
mrksiddiqui
Enthusiast
Enthusiast

Here is documentation that can guide you to get the custom script working.

http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vsphere.vm_admin.doc_50%2FGUID-75232...

If this helps answer your question please consider awarding points!
0 Kudos
gottr
Contributor
Contributor

This is what I use to get an IP address, create the customization spec, and clone from the template.

#vlan125   
    if ($vlan -eq 'vlan125'){
        $valid = $true
        foreach($i in 254..3)
        {
            $ip = "111.111.1.$i"
            If (Test-Connection -comp $ip -count 1 -quiet) {
                write-host -ForegroundColor Green "Computer online $ip"
            }
            Else {
                "Computer offline $ip"
                try{
                    $HostName = [System.Net.Dns]::GetHostByAddress($ip).HostName
                    $hostname
                }
                catch{
                    write-host -ForegroundColor Red "This is the $ip that will be used.";
                    $valid=$false;
                    break
                }
            }
        }
        if ($valid -eq $true){
            write-host -ForegroundColor Red "Alert there are no available IP address for $vlan"
        }
        $SUB = '255.255.255.0'
        $Gateway = '111.111.11.1'
    }


$custSpec = New-OSCustomizationSpec -Type NonPersistent -OSType Windows `
-OrgName “WORK” -FullName "$LocalAdminAccount" -Domain “WORK.HOME” `
-DomainUsername $usr -DomainPassword $pss -LicenseMode PerSeat `
-AdminPassword "This is the password" -NamingScheme Fixed -NamingPrefix $newVMName -TimeZone 035 -ChangeSid

#Modify the default network configuration settings
$custSpec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping `
-IpMode UseStaticIP -IpAddress $IP -SubnetMask $SUB `
-Dns $DNS -DefaultGateway $Gateway -Wins $WINS

#Deploy a VM from a template
$clonetask = New-VM -Name "$newVMName" -Template "$template" -VMHost "$tgtEsxName" -Datastore "$tgtDatastoreName" `
-OSCustomizationSpec $custSpec

0 Kudos
Morotalizer
Contributor
Contributor

Hi

Can you provide some step by step on how your implementation looks like?

Regards

Tatsumi

0 Kudos