Windows 10, Hyper-V and Wireless – Yes, Hyper-V also can do NAT

Set up a NAT network

Windows 10 Hyper-V allows native network address translation (NAT) for a virtual network.

This guide will walk you through:

  • creating a NAT network
  • connecting an existing virtual machine to your new network
  • confirming that the virtual machine is connected correctly


  • Windows 10 Anniversary Update or later
  • Hyper-V is enabled
Note: Currently, you to create one NAT network per host.

NAT Overview

NAT gives a virtual machine access to network resources using the host computer’s IP address and a port through an internal Hyper-V Virtual Switch.

Network Address Translation (NAT) is a networking mode designed to conserve IP addresses by mapping an external IP address and port to a much larger set of internal IP addresses. Basically, a NAT uses a flow table to route traffic from an external (host) IP Address and port number to the correct internal IP address associated with an endpoint on the network (virtual machine, computer, container, etc.)

Additionally, NAT allows multiple virtual machines to host applications that require identical (internal) communication ports by mapping these to unique external ports.

For all of these reasons, NAT networking is very common for container technology


Create a NAT virtual network

Let’s walk through setting up a new NAT network.

  1. Open a PowerShell console as Administrator.
  2. Create an internal switch
    New-VMSwitch -SwitchName "SwitchName" -SwitchType Internal
  3. Configure the NAT gateway using New-NetIPAddress.

    Here is the generic command:

    New-NetIPAddress -IPAddress  -PrefixLength  -InterfaceIndex 

    In order to configure the gateway, you’ll need a bit of information about your network:

    • IPAddress — NAT Gateway IP specifies the IPv4 or IPv6 address to use as the NAT gateway IP.
      The generic form will be a.b.c.1 (e.g. While the final position doesn’t have to be .1, it usually is (based on prefix length)

      A common gateway IP is

    • PrefixLength — NAT Subnet Prefix Length defines the NAT local subnet size (subnet mask). The subnet prefix length will be an integer value between 0 and 32.

      0 would map the entire internet, 32 would only allow one mapped IP. Common values range from 24 to 12 depending on how many IPs need to be attached to the NAT.

      A common PrefixLength is 24 — this is a subnet mask of

    • InterfaceIndex — ifIndex is the interface index of the virtual switch created above.

      You can find the interface index by running Get-NetAdapter

      Your output should look something like this:

      PS C:\> Get-NetAdapter
      Name                  InterfaceDescription               ifIndex Status       MacAddress           LinkSpeed
      ----                  --------------------               ------- ------       ----------           ---------
      vEthernet (intSwitch) Hyper-V Virtual Ethernet Adapter        24 Up           00-15-5D-00-6A-01      10 Gbps
      Wi-Fi                 Marvell AVASTAR Wireless-AC Net...      18 Up           98-5F-D3-34-0C-D3     300 Mbps
      Bluetooth Network ... Bluetooth Device (Personal Area...      21 Disconnected 98-5F-D3-34-0C-D4       3 Mbps

      The internal switch will have a name like vEthernet (SwitchName) and an Interface Description of Hyper-V Virtual Ethernet Adapter.

    Run the following to create the NAT Gateway:

    New-NetIPAddress -IPAddress -PrefixLength 24 -InterfaceIndex 24
  4. Configure the NAT network using New-NetNat.

    Here is the generic command:

    New-NetNat -Name  -InternalIPInterfaceAddressPrefix 

    In order to configure the gateway, you’ll need to provide information about the network and NAT Gateway:

    • Name — NATOutsideName describes the name of the NAT network. You’ll use this to remove the NAT network.
    • InternalIPInterfaceAddressPrefix — NAT subnet prefix describes both the NAT Gateway IP prefix from above as well as the NAT Subnet Prefix Length from above.

      The generic form will be a.b.c.0/NAT Subnet Prefix Length

      From the above, for this example, we’ll use

    For our example, run the following to set up the NAT network:

    New-NetNat -Name MyNATnetwork -InternalIPInterfaceAddressPrefix

Congratulations! You now have a virtual NAT network!

Connect a virtual machine

To connect a virtual machine to your new NAT network, connect the internal switch you created in the first step of the NAT Network Setup section to your virtual machine using the VM Settings menu.


Since WinNAT by itself does not allocate and assign IP addresses to an endpoint (e.g. VM), you will need to do this manually from within the VM itself – i.e. set IP address within range of NAT internal prefix, set default gateway IP address, set DNS server information. The only caveat to this is when the endpoint is attached to a container. In this case, the Host Network Service (HNS) allocates and uses the Host Compute Service (HCS) to assign the IP address, gateway IP, and DNS info to the container directly.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s