Mar 26 2020 05:17 PM
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.
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.
Mar 27 2020 11:07 AM
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.
Mar 27 2020 02:08 PM
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
Mar 29 2020 03:42 AM
Mar 30 2020 09:12 PM
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
Mar 31 2020 02:42 PM
Apr 01 2020 08:43 AM
Solution
The change has been merged into the official script. https://github.com/Azure/azure-devtestlab/commit/7da56e5fce7524ba8be3a8f1369b50452a8d0e11
Thanks,
Elizabeth
Apr 01 2020 05:55 PM
Apr 01 2020 08:43 AM
Solution
The change has been merged into the official script. https://github.com/Azure/azure-devtestlab/commit/7da56e5fce7524ba8be3a8f1369b50452a8d0e11
Thanks,
Elizabeth