Skip to content

Instantly share code, notes, and snippets.

@mttaggart
Created December 13, 2021 23:34
Show Gist options
  • Save mttaggart/1fd5c6f36fed7a34cc4c76fb68d44f21 to your computer and use it in GitHub Desktop.
Save mttaggart/1fd5c6f36fed7a34cc4c76fb68d44f21 to your computer and use it in GitHub Desktop.
Hyper-V Port Forwarding
New-VMSwitch -SwitchName "NATSwitch" -SwitchType Internal
New-NetIPAddress -IPAddress 192.168.10.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NATSwitch)"
New-NetNAT -Name "NATNetwork" -InternalIPInterfaceAddressPrefix 192.168.10.0/24
# Make sure target VM has an interfaces on the new switch
Add-NetNatStaticMapping -ExternalIPAddress "0.0.0.0/24" -ExternalPort 22 -Protocol TCP -InternalIPAddress "192.168.10.2" -InternalPort 22 -NatName NATNetwork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment