Last active
June 8, 2023 10:08
-
-
Save mreferre/8dd8cd0025880ada9f5b53d64df5210e to your computer and use it in GitHub Desktop.
PS commands to create a Hyper-V internal switch and NAT rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the following 3 lines of PowerShell creates an Internal Switch on Hyper-V (https://www.petenetlive.com/KB/Article/0001384) | |
New-VMSwitch -SwitchName "NAT-Switch" -SwitchType Internal | |
New-NetIPAddress -IPAddress 192.168.200.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NAT-Switch)" | |
New-NetNAT -Name "NAT-Network" -InternalIPInterfaceAddressPrefix 192.168.200.0/24 | |
# the following line of PowerShell creates a DNAT rule (80->80) from the outside into a VM (previously created an running on the Switch with IP .10) (https://www.petri.com/create-nat-rules-hyper-v-nat-virtual-switch) | |
Add-NetNatStaticMapping -ExternalIPAddress "0.0.0.0/24" -ExternalPort 80 -Protocol TCP -InternalIPAddress "192.168.200.10" -InternalPort 80 -NatName NAT-Network |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment