SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-1257382%22%20slang%3D%22en-US%22%3EInternet%20issues%20with%20Nested%20Virtualization%20Hyper-V%20VMs%20when%20publishing%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1257382%22%20slang%3D%22en-US%22%3E%3CP%3EOn%20a%20number%20of%20occassions%20when%20we%20deploy%20an%20existing%20template%20or%20publish%20a%20template%20for%20our%20Hyper-V%20classes%2C%20the%20Hyper-V%20VMs%20lose%20the%20ability%20to%20connect%20to%20the%20internet.%20After%20some%20playing%20around%20I%20found%20that%20the%20NetNat%20service%20often%20fails%20to%20run%20which%20causes%20the%20internet%20to%20not%20work%20through%20the%20Nat%20created%20on%20the%20host%20VM%20template.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20anyone%20else%20getting%20this%20issue%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20setup%20the%20NAT%20to%20allow%20internet%20access%20to%20the%20Hyper-V%20VMs%2C%20I%20run%20the%20script%20provided%20by%20MS%20doco%20on%20Azure%20Lab%20Services%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Flab-services%2Fclassroom-labs%2Fhow-to-enable-nested-virtualization-template-vm-using-script%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Flab-services%2Fclassroom-labs%2Fhow-to-enable-nested-virtualization-template-vm-using-script%3C%2FA%3E).%20I%20run%20this%20on%20the%20template%20before%20publishing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20not%20sure%20how%20the%20Nat%20service%20works%20but%20WinNat%20service%20isn't%20visible%20in%20the%20Services.msc%20gui%20or%20if%20you%20do%20a%20%22get-service%20-Name%20*%22%20in%20Powershell.%20To%20verify%20if%20the%20NAT%20service%20is%20running%2C%20run%20Get-NetNat%20and%20you%20should%20see%20if%20the%20Nat%20Active%20status%20is%20True%20or%20False.%20If%20it's%20false%2C%20internet%20won't%20work%20for%20your%20Hyper-V%20VMs.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-left%22%20image-alt%3D%22get-netnat.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F179863iF7BB4B7EE2B38261%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22get-netnat.jpg%22%20alt%3D%22get-netnat.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20fix%20it%20I%20put%20a%20script%20on%20the%20template%20and%20get%20it%20to%20run%20when%20the%20user%20logs%20into%20the%20VM%20via%20registry%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ECheck_NetNat_Service.ps1%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CEM%3E%3CBR%20%2F%3E%24netnat%20%3D%20Get-NetNat%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3EIf%20(%24netnat.Active%20-eq%20%22False%22)%20%7B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3EStart-Service%20WinNat%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3EWrite-Host%20%22WinNat%20Service%20has%20been%20started%22%20-ForegroundColor%20Green%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%7D%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3EElse%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%7B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3EWrite-Host%20%22WinNat%20Service%20is%20already%20running%22%20-ForegroundColor%20Cyan%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%7D%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFrom%20what%20I%20can%20see.%20The%20publishing%20breaks%20or%20causes%20the%20NAT%20service%20to%20not%20run%20on%20the%20deployed%20VMs.%20This%20is%20a%20bit%20annoying%20to%20configure%20as%20most%20teachers%20won't%20understand%20how%20to%20fix%20this%2C%20so%20I%20need%20to%20set%20this%20up%20for%20these%20types%20of%20labs.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1257382%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELab%20Services%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1259783%22%20slang%3D%22en-US%22%3ERe%3A%20Internet%20issues%20with%20Nested%20Virtualization%20Hyper-V%20VMs%20when%20publishing%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1259783%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Erwin%2C%3C%2FP%3E%0A%3CP%3EIt's%20great%20to%20see%20you%20in%20the%20forum!%20Let%20me%20connect%20you%20with%20the%20author%20of%20the%20nested%20virtualization%20article%20to%20see%20if%20she%20can%20help.%20I'll%20ask%20her%20to%20respond%20here%20once%20she%20investigates.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1260146%22%20slang%3D%22en-US%22%3ERe%3A%20Internet%20issues%20with%20Nested%20Virtualization%20Hyper-V%20VMs%20when%20publishing%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1260146%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F597118%22%20target%3D%22_blank%22%3E%40ErwinManuel%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20sorry%20to%20hear%20that%20you%20are%20experiencing%20issues%20with%20the%20enable%20nested%20virtualization%20script.%20It%20sounds%20like%20you%20found%20a%20work-around%20at%20least%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDoes%20this%20happen%20when%20you%20publish%20a%20template%20with%20a%20shared%20username%2Fpassword%20or%20when%20you%20publish%20a%20template%20where%20the%20student%20sets%20their%20own%20password%3F%26nbsp%3B%20I%20would%20like%20to%20do%20a%20little%20experimenting%20on%20my%20end%20and%20update%20the%20script.%26nbsp%3B%20Maybe%20add%20your%20solution%20to%20the%20official%20script%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%2C%3C%2FP%3E%0A%3CP%3EElizabeth%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1262242%22%20slang%3D%22en-US%22%3ERe%3A%20Internet%20issues%20with%20Nested%20Virtualization%20Hyper-V%20VMs%20when%20publishing%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1262242%22%20slang%3D%22en-US%22%3EHi%20Elizabeth%3CBR%20%2F%3E%3CBR%20%2F%3EYes%2C%20the%20workaround%20is%20working%20well.%20The%20template%20is%20using%20a%20shared%20username%20and%20password.%3CBR%20%2F%3E%3CBR%20%2F%3ECheers%3CBR%20%2F%3EErwin.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1266546%22%20slang%3D%22en-US%22%3ERe%3A%20Internet%20issues%20with%20Nested%20Virtualization%20Hyper-V%20VMs%20when%20publishing%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1266546%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F597118%22%20target%3D%22_blank%22%3E%40ErwinManuel%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20for%20the%20information.%26nbsp%3B%20I'm%20the%20glad%20you%20found%20an%20effective%20work-around.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20did%20a%20little%20research%2C%20and%20I%20think%20adding%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20Set-Service%20-Name%20WinNat%20-StartupType%20Automatic%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3Ewill%20fix%20the%20problem.%26nbsp%3B%20It's%20essentially%20the%20same%20thing%20your%20workaround%20does.%26nbsp%3B%20I'm%20going%20to%20do%20a%20little%20more%20testing%20and%20then%20submit%20a%20fix%20to%20the%20official%20script.%26nbsp%3B%20I'll%20update%20this%20thread%20when%20this%20is%20done.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EThank%20you%20for%20bring%20this%20issue%20to%20our%20attention.%26nbsp%3B%20I%20appreciate%20it.%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EThanks%2C%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EElizabeth%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1269404%22%20slang%3D%22en-US%22%3ERe%3A%20Internet%20issues%20with%20Nested%20Virtualization%20Hyper-V%20VMs%20when%20publishing%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1269404%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F281809%22%20target%3D%22_blank%22%3E%40planetmaher%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPerfect!%20Makes%20sense%20to%20have%20that%20service%20running%20at%20startup.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1271972%22%20slang%3D%22en-US%22%3ERe%3A%20Internet%20issues%20with%20Nested%20Virtualization%20Hyper-V%20VMs%20when%20publishing%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1271972%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F597118%22%20target%3D%22_blank%22%3E%40ErwinManuel%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20change%20has%20been%20merged%20into%20the%20official%20script.%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-devtestlab%2Fcommit%2F7da56e5fce7524ba8be3a8f1369b50452a8d0e11%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure%2Fazure-devtestlab%2Fcommit%2F7da56e5fce7524ba8be3a8f1369b50452a8d0e11%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%2C%3C%2FP%3E%0A%3CP%3EElizabeth%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1273284%22%20slang%3D%22en-US%22%3ERe%3A%20Internet%20issues%20with%20Nested%20Virtualization%20Hyper-V%20VMs%20when%20publishing%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1273284%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F281809%22%20target%3D%22_blank%22%3E%40planetmaher%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFantastic%2C%20thanks%20so%20much%20for%20resolving%20this.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional 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.