Skip to content

Instantly share code, notes, and snippets.

@gaelcolas
Created January 3, 2017 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaelcolas/4dcd3cc78bc7a39f2809ba10a618dd49 to your computer and use it in GitHub Desktop.
Save gaelcolas/4dcd3cc78bc7a39f2809ba10a618dd49 to your computer and use it in GitHub Desktop.
$containerPrefix = '10.111.110.0/24'
$sharedPrefix = '10.111.0.0/16'
$vmprefix = '10.111.111.0/24'
$vmPrefixLength = 24
$SharedGw = '10.111.111.1'
$vmNatSwitchName = 'NAT'
$null = Get-ContainerNetwork | Remove-ContainerNetwork -Force -ErrorAction SilentlyContinue
$null = Get-NetNat | Remove-NetNat -Confirm:$false -ErrorAction SilentlyContinue
$null = Get-VMSwitch -Name $vmNatSwitchName -ErrorAction SilentlyContinue | Remove-VMSwitch -Force -Confirm:$false -ErrorAction Stop
$containerNetwork = New-ContainerNetwork -Name nat -Mode NAT -SubnetPrefix $containerPrefix -GatewayAddress $SharedGw
$null = Get-NetNat | Remove-NetNat -Confirm:$false
$SharedNat = New-NetNat -Name SharedNAT -InternalIPInterfaceAddressPrefix $sharedPrefix
$vswitch = New-VMSwitch -Name $vmNatSwitchName -SwitchType Internal -Notes 'VM NAT SWITCH' -Confirm:$false
$nic = Get-NetAdapter | ? Name -Match $vswitch.Name
$HostSwitchIP = New-NetIPAddress -IPAddress $SharedGw -InterfaceIndex $nic.ifIndex -DefaultGateway $SharedGw -PrefixLength 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment