Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
azure_gw_ipsec_setup.ps1
#default to msdn sub
Set-AzContext -Subscription "716f03d6-acff-467c-bca4-3c8eb56f549d"
# https://docs.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-tutorial-create-gateway-powershell
##Notes
10.1.220.0/23 ## Address Space
10.1.220.0/24 ## Frontend
10.1.221.0/24 ## Backend
10.1.223.0/27 ## GW Routing Subnet
#params
$RG1 = "DSA-LAB"
$VNet1 = "DSA-AZURELAB-VNET1"
$Location1 = "West US"
$FESubnet1 = "Default"
$BESubnet1 = "Backend"
$GwSubnet1 = "GatewaySubnet"
$VNet1Prefix = "10.1.208.0/20"
$FEPrefix1 = "10.1.220.0/24"
$BEPrefix1 = "10.1.221.0/24"
$GwPrefix1 = "10.1.223.0/27"
$VNet1ASN = 65010
$DNS1 = "8.8.8.8"
$Gw1 = "VNet1GW"
$GwIP1 = "VNet1GWIP"
$GwIPConf1 = "gwipconf1"
#Setup networks
$fesub1 = New-AzVirtualNetworkSubnetConfig -Name $FESubnet1 -AddressPrefix $FEPrefix1
$besub1 = New-AzVirtualNetworkSubnetConfig -Name $BESubnet1 -AddressPrefix $BEPrefix1
$gwsub1 = New-AzVirtualNetworkSubnetConfig -Name $GWSubnet1 -AddressPrefix $GwPrefix1
$vnet = New-AzVirtualNetwork `
-Name $VNet1 `
-ResourceGroupName $RG1 `
-Location $Location1 `
-AddressPrefix $VNet1Prefix `
-Subnet $fesub1,$besub1,$gwsub1
#Request Public IP for GW object
$gwpip = New-AzPublicIpAddress -Name $GwIP1 -ResourceGroupName $RG1 `
-Location $Location1 -AllocationMethod Dynamic
#Create subnet object
$subnet = Get-AzVirtualNetworkSubnetConfig -Name 'GatewaySubnet' `
-VirtualNetwork $vnet
#Create the GW Conf Config
$gwipconf = New-AzVirtualNetworkGatewayIpConfig -Name $GwIPConf1 `
-Subnet $subnet -PublicIpAddress $gwpip
#Create the gateway
New-AzVirtualNetworkGateway -Name $Gw1 -ResourceGroupName $RG1 `
-Location $Location1 -IpConfigurations $gwipconf -GatewayType Vpn `
-VpnType RouteBased -GatewaySku VpnGw1
#VPN Setup
# Virtual network
$RG1 = "DSA-LAB"
$VNet1 = "VNet1"
$Location1 = "West US"
$VNet1Prefix = "10.1.208.0/20"
$VNet1ASN = 65010
$Gw1 = "VNet1GW"
# On-premises network - LNGIP1 is the VPN device public IP address
$LNG1 = "DSA_CCDC"
$LNGprefix1 = "10.1.100.0/24"
$LNGIP1 = "207.231.83.253"
# Connection
$Connection1 = "Azure_lab_to_dsa_ccdc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.