VMware Horizon Community
BrandenTimm
Contributor
Contributor

Set DNS after Linked Clone deployment

I'm currently evaluating View 4.6 on top of our vSphere 4.1 Update 1 environment.

My problem relates to getting DNS set properly for the ethernet adapters in linked clones. DHCP currently hands out an external DNS service, not our internal Active Directory which has the records for our View Connection server and AD DC's.

I set the DNS statically on the adapter in the parent image, but it appears that this NIC is being removed and replaced when linked clones are deployed because the adapters in the linked clones have the label "Local Area Connection 2".

I tried adding a post-synchronization QuickPrep script to do this.  It points to a .bat file with the two lines:

netsh interface ip set dns "Local Area Connection 2" static <AD DC 1 ip>

netsh interface ip add dns "Local Area Connection 2" <AD DC 2 ip> index=2

This does not however seem to have any effect, or it is being overwritten by DHCP when the interface card comes up.

To fix the problem of finding our View connection server, I added a static host entry to the parent image.  Now when I create the pool, it fails at the Customizing stage with the error: View Composer agent initialization state error (18): Failed to join the domain (waited 730 seconds)

I understand it can't find my DCs, and I don't think I can remedy this by putting entries in the hosts file since the machine still wouldn't know that the hosts specified there are DCs to be used to join the domain.

How can I set the proper DNS automatically after the linked clones are deployed and get their initial DNS addresses from DHCP?

Cheers

0 Kudos
4 Replies
idle-jam
Immortal
Immortal

why not give more DNS servers (internal and external) from the DHCP servers?

0 Kudos
BrandenTimm
Contributor
Contributor

I was able to get things running by converting the parent vm to a template, selecting Deploy virtual machine from template, creating a System Configuration where I set the NIC to use DHCP with static DNS entries, and then configured my pool to use that spec.  Not sure if this is the best way to get things done, but it works.

0 Kudos
kgsivan
VMware Employee
VMware Employee

Set Static DNS in parent VM and take a new snapshot, then deploy pools from that snapshot. This should work for you.

Another solution is, create a Custom Spec in VC with static DNS, and during pool provisioning select sysprep customization and choose the created Custom Spec.

0 Kudos
don82
Contributor
Contributor

Ok I have been also trying to set DNS of linked-clones.  Here's what I did:

1. On parent Windows7 VDI I created a task that starts at boot time that will run powershell script that sets DNS of interfaces:

# Here's the task definition XML file that invokes powershell command on powershell script at "C:\Users\Public\SetDnsSearchOrder.ps1". You can import this in task scheduler.

<?xml version="1.0" encoding="UTF-16"?>

<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">

  <RegistrationInfo>

<Date>2016-11-16T12:06:38.6317955</Date>

    <Author>QA01\admin</Author>

  </RegistrationInfo>

  <Triggers>

    <BootTrigger>

      <Enabled>true</Enabled>

    </BootTrigger>

  </Triggers>

  <Principals>

    <Principal id="Author">

      <UserId>S-1-5-18</UserId>

<RunLevel>HighestAvailable</RunLevel>

    </Principal>

  </Principals>

  <Settings>

<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>

<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>

<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>

<AllowHardTerminate>true</AllowHardTerminate>

<StartWhenAvailable>false</StartWhenAvailable>

<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>

    <IdleSettings>

<StopOnIdleEnd>true</StopOnIdleEnd>

<RestartOnIdle>false</RestartOnIdle>

    </IdleSettings>

<AllowStartOnDemand>true</AllowStartOnDemand>

    <Enabled>true</Enabled>

    <Hidden>false</Hidden>

<RunOnlyIfIdle>false</RunOnlyIfIdle>

<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>

<UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>

    <WakeToRun>false</WakeToRun>

<ExecutionTimeLimit>P3D</ExecutionTimeLimit>

    <Priority>7</Priority>

  </Settings>

  <Actions Context="Author">

    <Exec>

<Command>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe</Command>

<Arguments>C:\Users\Public\SetDnsSearchOrder.ps1</Arguments>

    </Exec>

  </Actions>

</Task>

2. Thepowershell contains this commands.  This should vary based on your setup.

# Here's the poweshell script content of "C:\Users\Public\SetDnsSearchOrder.ps1" file

Get-WmiObject Win32_NetworkAdapterConfiguration `

  | Where-Object {$_.IPAddress -like "10.2*"} `

  | ForEach-Object {

$_.SetDNSServerSearchOrder(("10.2.38.16","10.2.38.17"))

    }

3. Shutdown the parent VDI and take snapshot. Then power it up and use this updated parent/snap in provisioning linked-clones

4. Then the new linked-clone will have this DNS config on their DHCP enabled interfaces upon bootup.

0 Kudos