在 Azure 中点到站点和站点到站点网络之间路由

在 Azure 中点到站点和站点到站点网络之间路由

我是 Azure 新手,正在尝试使用 VPN 将这里的一台机器连接到 Azure 上的 VM。该 VM 位于较新的 Resource Manager 平台上。不幸的是,只有经典平台支持点到站点。因此,我添加了一个经典网络,并使用站点到站点 VPN 连接了两个网络。

VNet1(资源)-10.0.0.0/23

VNet2(经典)- 10.0.10.0/23

VNet2 网关还启用了点到站点。点到站点 IP 范围为 192.168.0.0/24。

我在这里的机器上下载了 VPN 客户端并连接到 VPN。我被分配了 192.168.0.5。

VPN 连接成功图像(抱歉,无法直接发布图片)

所有 VPN 连接似乎都在运行,但我无法从这里看到 VNet1 上的机器。ping/tracert 到 10.0.0.4 超时。

一篇文章我发现需要在 routes.txt 中添加一行用于 VPN 连接。第一行已经存在,我添加了第二行并重新连接了 VPN。

ADD 10.0.10.0 MASK 255.255.254.0 默认 METRIC 默认 IF 默认

添加 10.0.0.0 MASK 255.255.254.0 默认 METRIC 默认 IF 默认

没有运气。我检查了路由表,发现路由表里有 10.0.0.0。

IPv4 Route Table
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
<snip>
10.0.0.0    255.255.254.0         On-link       192.168.0.7     28
10.0.1.255  255.255.255.255         On-link       192.168.0.7    266
10.0.10.0    255.255.254.0         On-link       192.168.0.7     28
10.0.11.255  255.255.255.255         On-link       192.168.0.7    266
<snip>

我错过了什么?

答案1

谢谢!

微软昨晚发布了有关资源管理器点到站点连接的实际文章这里

(原文:这不是给你的直接答案,但根据这个[链接][1]

“使用 Azure 资源管理器部署模型创建的虚拟网络的点到站点连接现在可以通过 REST API 和 PowerShell 实现。”)

答案2

一位微软员工非常友善地发布了一个使用 Azure 资源管理器模型创建点对站点 VPN 的脚本。此功能目前尚未记录,但这个脚本对我来说很有用!(原始帖子

# Must created a subnet called GatewaySubnet for the gateway to connect prior to creating the gateway
$vnetname = "TestNetwork"
$rgname = "TestRG"
$region = "North Europe"
$clientpool = "192.168.10.0/24"
$RootCertName = "MyRootCert.cer"  
$publicCertData = "<Replace_With_Your_Base64_Cert_Data>"; #Export cert as Base64, and put data into single line.

#Login to Azure RM
Login-AzureRMAccount

# Get the Virtual Network
$vnet = Get-AzureRmVirtualNetwork -Name $vnetname -ResourceGroupName $rgname

#Create IP for the gateway
$GWIP = New-AzureRmPublicIpAddress -AllocationMethod Dynamic  -ResourceGroupName $rgname -Location $region  -Name GWIP1

#Get the gateway subnet
$GWSubnet = Get-AzureRmVirtualNetworkSubnetConfig  -Name GatewaySubnet -VirtualNetwork $vnet

# Create GW Config
$GWIPConfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name GWIPConfig -SubnetId $gwsubnet.Id -PublicIpAddressId $GWIP.Id

#Create Gateway
$gw = New-AzureRmVirtualNetworkGateway -Location $region  -Name GW1 -ResourceGroupName $rgname -GatewayType Vpn  -IpConfigurations $GWIPConfig -VpnType RouteBased 

# Create client VPN config
Set-AzureRmVirtualNetworkGatewayVpnClientConfig -VirtualNetworkGateway $gw -VpnClientAddressPool $clientpool

# Create Root Cert
$rootCert = Add-AzureRmVpnClientRootCertificate  -VpnClientRootCertificateName $RootCertName  -PublicCertData $publicCertData  -VirtualNetworkGatewayName $gw.Name -ResourceGroupName $rgname

#Get URL for VPN client - download the exe from here
$packageUrl = Get-AzureRmVpnClientPackage -ResourceGroupName $rgname -VirtualNetworkGatewayName $gw.Name -ProcessorArchitecture Amd64  

相关内容