forked from fabferri/az-pattern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDumpRoutes-VPNGateways.ps1
89 lines (77 loc) · 4.3 KB
/
DumpRoutes-VPNGateways.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
$subscriptionName = "AzureDemo3"
$rgName = "4"
$gtwName_dc0 = "gtw-dc0"
$gtwName_hub1 = "gtw-hub1"
$gtwName_hub2 = "gtw-hub2"
# select the Azure subscription
Set-AzContext $subscriptionName
# get the local BGP IP used to create BGP peering with neighbor
try {
$vpngtw_dc0=Get-AzVirtualNetworkGateway -Name $gtwName_dc0 -ResourceGroupName $rgName -ErrorAction Stop
$ip_vpn_gtw_dc0=$vpngtw_dc0.BgpSettings.BgpPeeringAddress
}
catch {
write-host "vpn gateway"$gtwName_dc0 "not found" -ForegroundColor Green
Exit
}
try {
$vpngtw_hub1=Get-AzVirtualNetworkGateway -Name $gtwName_hub1 -ResourceGroupName $rgName -ErrorAction Stop
$ip_vpn_gtw_hub1=$vpngtw_hub1.BgpSettings.BgpPeeringAddress
}
catch {
write-host "vpn gateway"$gtwName_hub1 "not found" -ForegroundColor Green
Exit
}
try {
$vpngtw_hub2=Get-AzVirtualNetworkGateway -Name $gtwName_hub2 -ResourceGroupName $rgName -ErrorAction Stop
$ip_vpn_gtw_hub2=$vpngtw_hub2.BgpSettings.BgpPeeringAddress
}
catch {
write-host "vpn gateway"$gtwName_hub2 "not found" -ForegroundColor Green
Exit
}
# Routes advertised from the VPN gateway to the remote BGP peers
write-host ""
write-host "Routes advertised from the gateway: "$gtwName_dc0 " to the peer:"$ip_vpn_gtw_hub2 -ForegroundColor Cyan
Get-AzVirtualNetworkGatewayAdvertisedRoute `
-VirtualNetworkGatewayName $gtwName_dc0 -ResourceGroupName $rgName -Peer $ip_vpn_gtw_hub2 | ft
write-host "----------------------------------------------------------------------------" -ForegroundColor Green
#
#
write-host "----------------------------------------------------------------------------" -ForegroundColor Green
write-host "Routes advertised from"$gtwName_hub1 "to the peer:"$ip_vpn_gtw_dc0 -ForegroundColor Cyan
Get-AzVirtualNetworkGatewayAdvertisedRoute `
-VirtualNetworkGatewayName $gtwName_hub1 -ResourceGroupName $rgName -Peer $ip_vpn_gtw_dc0 | ft
write-host "----------------------------------------------------------------------------" -ForegroundColor Green
write-host "Routes advertised from the gateway: "$gtwName_hub1 " to the peer:"$ip_vpn_gtw_hub2 -ForegroundColor Cyan
Get-AzVirtualNetworkGatewayAdvertisedRoute `
-VirtualNetworkGatewayName $gtwName_hub1 -ResourceGroupName $rgName -Peer $ip_vpn_gtw_hub2 | ft
write-host "----------------------------------------------------------------------------" -ForegroundColor Green
#
#
write-host "----------------------------------------------------------------------------" -ForegroundColor Green
write-host "Routes advertised from"$gtwName_hub2 "to the peer:"$ip_vpn_gtw_dc0 -ForegroundColor Cyan
Get-AzVirtualNetworkGatewayAdvertisedRoute `
-VirtualNetworkGatewayName $gtwName_hub2 -ResourceGroupName $rgName -Peer $ip_vpn_gtw_dc0 | ft
write-host "----------------------------------------------------------------------------" -ForegroundColor Green
write-host "Routes advertised from the gateway: "$gtwName_hub2 " to the peer:"$ip_vpn_gtw_hub1 -ForegroundColor Cyan
Get-AzVirtualNetworkGatewayAdvertisedRoute `
-VirtualNetworkGatewayName $gtwName_hub2 -ResourceGroupName $rgName -Peer $ip_vpn_gtw_hub1 | ft
write-host "----------------------------------------------------------------------------" -ForegroundColor Green
###### Lists routes learned by an Azure VPN gateway
write-host "----------------------------------------------------------------------------" -ForegroundColor Yellow
write-host "List of routes learned in: "$gtwName_dc0
Get-AzVirtualNetworkGatewayLearnedRoute `
-VirtualNetworkGatewayName $gtwName_dc0 `
-ResourceGroupName $rgName | ft
write-host "----------------------------------------------------------------------------" -ForegroundColor Yellow
write-host "List of routes learned in: "$gtwName_hub1
Get-AzVirtualNetworkGatewayLearnedRoute `
-VirtualNetworkGatewayName $gtwName_hub1 `
-ResourceGroupName $rgName | ft
write-host "----------------------------------------------------------------------------" -ForegroundColor Yellow
write-host "List of routes learned in: "$gtwName_hub2
Get-AzVirtualNetworkGatewayLearnedRoute `
-VirtualNetworkGatewayName $gtwName_hub2 `
-ResourceGroupName $rgName | ft
write-host "----------------------------------------------------------------------------" -ForegroundColor Yellow