Set Up NAT In Windows 10 Hyper-V

Windows 10 has a feature that allows to create NAT network in Hyper-V and put virtual machines behind the NAT. The steps to implement this are based on the Set up a NAT network article, I’ve reorganized it for simplicity.

All the steps must be performed from PowerShell console being run as Administrator.

1. Create Virtual Switch

My virtual switch will be named NAT, you will see it in Hyper-V manager. If everything is OK, you’ll see the following:

2. Find the interface index

Remember the ifIndex of a newly created virtual switch (named NAT).

3. Configure the NAT gateway

I will use subnet 172.16.0.x with mask 255.255.255.0. In this command you specify the IP address of the NAT default gateway 172.16.0.1 with 1 in the last position.

4. Create NAT network

In this command you specify subnet 172.16.0.0 with 0 in the last position.

 

Now you can check virtual switch. When you open Control Panel -> Network and Internet -> Network Connections, you will see adapter “vEthernet (NAT)”. It must be set to IP address 172.16.0.1 and subnet mask 255.255.255.0.

Inside virtual machine you should set up TCP/IPv4 properties for network adapter manually like this:

IP Address 172.16.0.2 or any other IP up to 172.16.0.254
Subnet mask 255.255.255.0
Default gateway 172.16.0.1
DNS server Place IP address of DNS server that is used on host network adapter, i.e. 192.168.1.1 or 8.8.8.8

7 Replies to “Set Up NAT In Windows 10 Hyper-V”

  1. New-NetNat -Name NatNetwork -InternalIPInterfaceAddressPrefix 192.168.0.0/24

    returns an error:

    New-NetNat : The parameter is incorrect.
    At line:1 char:1
    + New-NetNat -Name NatNetwork -InternalIPInterfaceAddressPrefix 192.168 …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (MSFT_NetNat:root/StandardCimv2/MSFT_NetNat) [New-NetNat], CimException
    + FullyQualifiedErrorId : Windows System Error 87,New-NetNat

    1. Its becuase you already have a netnat.

      Use Get-NetNat to know the name of the existing netnat and then delete the existing NetNat using Remove-netnat -Name “Name of the existing netnat”.

  2. Hi,
    Thanks for guide. It seems to work.
    Did anyone notice a performance hit to internet speed? I can’t update windows even when I go to the download site. Is there a default port forwarding rule for port 80 ? Does a person need to define other port forwarding rules to have other apps work through the NAT? Thanks for your time.

Leave a Reply

Your email address will not be published. Required fields are marked *