Skip to content

Instantly share code, notes, and snippets.

@kongou-ae
Created August 28, 2019 16:13
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 kongou-ae/6f16e3e19ae9f24cdfef8402c4a54438 to your computer and use it in GitHub Desktop.
Save kongou-ae/6f16e3e19ae9f24cdfef8402c4a54438 to your computer and use it in GitHub Desktop.
$region = "YOUR-REGION"
$rg = New-AzureRmResourceGroup -Location $region -Name "vnet-gateway"
$subnet = New-AzureRMVirtualNetworkSubnetConfig -Name 'gatewaysubnet' -AddressPrefix '10.254.0.0/27'
$ngwpip = New-AzureRMPublicIpAddress -Name ngwpip -ResourceGroupName $rg.ResourceGroupName -Location $region -AllocationMethod Dynamic
$vnet = New-AzureRmVirtualNetwork -AddressPrefix "10.254.0.0/27" -Location $region -Name vnet-gateway `
-ResourceGroupName $rg.ResourceGroupName -Subnet $subnet
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -name 'gatewaysubnet' -VirtualNetwork $vnet
$ngwipconfig = New-AzureRMVirtualNetworkGatewayIpConfig -Name ngwipconfig -SubnetId $subnet.Id -PublicIpAddressId $ngwpip.Id
New-AzureRmVirtualNetworkGateway -Name myNGW -ResourceGroupName $rg.ResourceGroupName -Location $region `
-IpConfigurations $ngwIpConfig -GatewayType "Vpn" -VpnType "RouteBased" -GatewaySku "Basic"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment