SOLVED

Internet issues with Nested Virtualization Hyper-V VMs when publishing template

Brass Contributor

On a number of occassions when we deploy an existing template or publish a template for our Hyper-V classes, the Hyper-V VMs lose the ability to connect to the internet. After some playing around I found that the NetNat service often fails to run which causes the internet to not work through the Nat created on the host VM template. 

 

Is anyone else getting this issue?

 

To setup the NAT to allow internet access to the Hyper-V VMs, I run the script provided by MS doco on Azure Lab Services (https://docs.microsoft.com/en-us/azure/lab-services/classroom-labs/how-to-enable-nested-virtualizati...). I run this on the template before publishing.

 

I'm not sure how the Nat service works but WinNat service isn't visible in the Services.msc gui or if you do a "get-service -Name *" in Powershell. To verify if the NAT service is running, run Get-NetNat and you should see if the Nat Active status is True or False. If it's false, internet won't work for your Hyper-V VMs.

 

get-netnat.jpg

 

To fix it I put a script on the template and get it to run when the user logs into the VM via registry

 

Check_NetNat_Service.ps1


$netnat = Get-NetNat

If ($netnat.Active -eq "False") {

Start-Service WinNat

Write-Host "WinNat Service has been started" -ForegroundColor Green

}

Else

{

Write-Host "WinNat Service is already running" -ForegroundColor Cyan

}

 

From what I can see. The publishing breaks or causes the NAT service to not run on the deployed VMs. This is a bit annoying to configure as most teachers won't understand how to fix this, so I need to set this up for these types of labs.

7 Replies

Hi Erwin,

It's great to see you in the forum! Let me connect you with the author of the nested virtualization article to see if she can help. I'll ask her to respond here once she investigates. 

@ErwinManuel,

 

I'm sorry to hear that you are experiencing issues with the enable nested virtualization script. It sounds like you found a work-around at least?

 

Does this happen when you publish a template with a shared username/password or when you publish a template where the student sets their own password?  I would like to do a little experimenting on my end and update the script.  Maybe add your solution to the official script?

 

Thanks,

Elizabeth

Hi Elizabeth

Yes, the workaround is working well. The template is using a shared username and password.

Cheers
Erwin.

@ErwinManuel,

 

Thanks for the information.  I'm the glad you found an effective work-around.

 

I did a little research, and I think adding

 Set-Service -Name WinNat -StartupType Automatic
will fix the problem.  It's essentially the same thing your workaround does.  I'm going to do a little more testing and then submit a fix to the official script.  I'll update this thread when this is done.
 
Thank you for bring this issue to our attention.  I appreciate it.  
 
Thanks,
Elizabeth

@planetmaher 

 

Perfect! Makes sense to have that service running at startup. 

best response confirmed by planetmaher (Microsoft)

@planetmaher 

 

Fantastic, thanks so much for resolving this.

1 best response

Accepted Solutions
best response confirmed by planetmaher (Microsoft)