Configuring NAT for Hyper-V VMs

# Create new switch  
New-VMSwitch -SwitchName NAT -SwitchType Internal

# You can find the interface index by running: Get-NetAdapter

# Run the following to create the NAT Gateway:

New-NetIPAddress -IPAddress 192.168.4.1 -PrefixLength 24 -InterfaceIndex 53

# Configure the NAT network

New-NetNat -Name NAT -InternalIPInterfaceAddressPrefix “192.168.4.0/24”

# Add a static mapping to a NAT

A static mapping enables an incoming connection from an external network to access a host on an internal network through the NAT.


Add-NetNatStaticMapping -NatName NAT -Protocol TCP -ExternalIPAddress "0.0.0.0/24" -ExternalPort 80 -InternalIPAddress "192.168.4.20" -InternalPort 80

One thought on “Configuring NAT for Hyper-V VMs

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s