Internet is unreachable from Hyper-V VMs through custom NAT

Cal Dooras 1 Reputation point

I'm trying to set up a NAT on Windows 10 to provide Hyper-V VMs with access to both Internet and Cisco AnyConnect VPN configured on the host machine. In accordance with this manual I executed the following PowerShell script:

New-VMSwitch -SwitchName 'VM NAT switch' -SwitchType Internal  
New-NetIPAddress -IPAddress '' -PrefixLength 24 -InterfaceAlias 'vEthernet (VM NAT switch)'  
New-NetNat -Name 'VM NAT' -InternalIPInterfaceAddressPrefix ''  

The script was successfully completed and VM NAT Switch was assigned to a VM. But the IP address the VM was provided with at startup was 169.254.x.x, not 192.168.2.x. Then I tried to configure network connection in the VM manually as, default gateway The settings was accepted, but the network was still unreachable:
I can ping the default gateway from the VM, though.

In the same time the network is reachable when Hyper-V Default Switch is used instead of my custom vSwitch. But I need to forward some ports through the NAT and I don't know how to do that with Default Switch.

What have I missed in the NAT configuration?

A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,598 questions
0 comments No comments
{count} votes