48 lines
1.6 KiB
PowerShell
48 lines
1.6 KiB
PowerShell
azure powershell
|
|
|
|
# Virtual network
|
|
$RG1 = "resource_west_eu_api_test"
|
|
$VNet1 = "west-Eu-Api-2"
|
|
$Location1 = "West Europe"
|
|
$VNet1Prefix = "10.50.0.0/16"
|
|
$VNet1ASN = 65010
|
|
$Gw1 = "virutal-gateway"
|
|
|
|
# On-premises network - LNGIP1 is the VPN device public IP address
|
|
$LNG1 = "VPNsite1"
|
|
$LNGprefix1 = "10.100.102.0/24"
|
|
$LNGIP1 = "195.215.105.8"
|
|
|
|
# Connection
|
|
$Connection1 = "VNet1ToSite1"
|
|
|
|
New-AzLocalNetworkGateway -Name $LNG1 -ResourceGroupName $RG1 `
|
|
-Location $Location1 -GatewayIpAddress $LNGIP1 -AddressPrefix $LNGprefix1
|
|
|
|
$vng1 = Get-AzVirtualNetworkGateway -Name $GW1 -ResourceGroupName $RG1
|
|
$lng1 = Get-AzLocalNetworkGateway -Name $LNG1 -ResourceGroupName $RG1
|
|
|
|
|
|
New-AzVirtualNetworkGatewayConnection -Name $Connection1 -ResourceGroupName $RG1 `
|
|
-Location $Location1 -VirtualNetworkGateway1 $vng1 -LocalNetworkGateway2 $lng1 `
|
|
-ConnectionType IPsec -SharedKey "Azure@!b2C3" -ConnectionProtocol IKEv2
|
|
|
|
#to show key
|
|
#Get-AzVirtualNetworkGatewayConnectionSharedKey `
|
|
#-Name $Connection1 -ResourceGroupName $RG1
|
|
|
|
#to change the key
|
|
#Set-AzVirtualNetworkGatewayConnectionSharedKey `
|
|
#-Name $Connection1 -ResourceGroupName $RG1 `
|
|
#-Value "Azure@!_b2=C3"
|
|
|
|
$connection = Get-AzVirtualNetworkGatewayConnection -Name $Connection1 ` -ResourceGroupName $RG1
|
|
$newpolicy = New-AzIpsecPolicy ` -IkeEncryption AES256 -IkeIntegrity SHA256 -DhGroup DHGroup2 `
|
|
-IpsecEncryption AES128 -IpsecIntegrity SHA1 -PfsGroup PFS2048 `
|
|
-SALifeTimeSeconds 14400 -SADataSizeKilobytes 102400000
|
|
|
|
Set-AzVirtualNetworkGatewayConnection -VirtualNetworkGatewayConnection $connection `
|
|
-IpsecPolicies $newpolicy
|
|
|
|
|