# 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