question

JnisSimsons-8357 avatar image
JnisSimsons-8357 asked ·

How to open port to nested VM

I have a windows server VM in Azure that is running a Hyper-V VM on top of it.
The nested VM is running a database server on port: 1025

How can I connect to the nested VM's database from outside the network?

I followed this MS article on setting up routing: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/nested-virtualization-azure-virtual-network#install-and-configure-dhcp

That helped with connectivity from nested VM to the internet. But I cannot connect to the nested VM from outside.

I tried creating a NAT port redirection rule under "Routing and Remote Access" -> IPv4 -> NAT -> 'Services and Ports' like this:
https://i.imgur.com/bjLK4wN.png
But that didn't help.

What else needs to be configured?

Thank you

azure-virtual-machines-networking
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JnisSimsons-8357 avatar image
JnisSimsons-8357 answered ·

I fixed this issue.
If anyone else is looking for a solution you must add NAT static mapping with powershell:

Add-NetNatStaticMapping -NatName "NestedSwitch" -Protocol TCP -ExternalIPAddress 0.0.0.0 -InternalIPAddress 10.4.2.2 -InternalPort 1025 -ExternalPort 1025

"NestedSwitch" is the virtual switch which is created if you follow the MS article mentioned in the post above.

1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for sharing the update. Please mark your solution as accepted answer so that it can help others in the community.

0 Votes 0 · ·