Last active
September 8, 2017 13:59
-
-
Save johnrizzo1/e8f93c8c75a1cad438e60d6370e5bfde to your computer and use it in GitHub Desktop.
Hyperv Nat Setup
This file contains hidden or 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
$switchName = "nat_switch" | |
$network = "192.168.0.0" | |
$networkMask = "24" | |
$defaultGateway = "192.168.0.1" | |
New-VMSwitch -SwitchName $switchName -SwitchType Internal | |
$networkAdapter = Get-NetAdapter | where { $_.Name -eq "vEthernet ($switchName)" } | |
New-NetIPAddress -IPAddress $defaultGateway -PrefixLength $networkMask -InterfaceIndex $networkAdapter.ifIndex | |
New-NetNat -Name $networkAdapter.ifIndex -InternalIPInterfaceAddressPrefix $network/$networkMask | |
# References | |
# https://4sysops.com/archives/native-nat-in-windows-10-hyper-v-using-a-nat-virtual-switch/ | |
# https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/setup-nat-network | |
# https://www.petri.com/configuring-vm-networking-hyper-v-nat-switch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment