简体   繁体   English

无法通过天蓝色的ARM VPN连接中的Rasdial连接

[英]Not able to connect through Rasdial in azure ARM VPN connection

I am not able connect to VPN using powershell cmdlet. 我无法使用Powershell cmdlet连接到VPN。 I use 'rasdial' from a build agent to connect to vpn, so that we can trigger automated tests. 我使用来自构建代理的“ rasdial”连接到vpn,以便我们可以触发自动化测试。 The whole process is automated. 整个过程是自动化的。

Earlier same rasdial command - Rasdial "VPNName" was working perfectly fine with classic model (ASM) of vpn. 先前相同的rasdial命令Rasdial "VPNName"与vpn的经典模型(ASM)完美配合。 But, after I migrated to ARM, I am facing this issue. 但是,在迁移到ARM之后,我面临着这个问题。 However through UI ie clicking on buttons to connect to vpn is working fine but our need is to connect through script. 但是,通过UI,即单击按钮以连接到VPN可以正常工作,但我们需要通过脚本进行连接。

I am getting a message- 我收到一条消息-

This function is not supported on this system. 该系统不支持此功能。

NB: I am following this post- https://dzone.com/articles/deconstructing-azure-point 注意:我正在关注这个帖子-https ://dzone.com/articles/deconstructing-azure-point

The same workaround worked in ASM but not woking in ARM. 相同的解决方法在ASM中有效,但在ARM中无法正常工作。 What can be another workaround or fix for this ? 有什么其他解决方法或可以解决此问题?

I am using below script to create and download the VPN package. 我正在使用以下脚本创建和下载VPN软件包。 I am not sure I am missing something in my script which is causing this issue- 我不确定我的脚本中是否缺少某些导致此问题的信息-

$VNetName  = "MYVPN"
$SubName = "Subnet-1"
$GWSubName = "GatewaySubnet"
$VNetPrefix1 = "15.3.0.0/16"
$SubPrefix = "15.3.1.0/24"
$GWSubPrefix = "15.3.200.0/26"
$VPNClientAddressPool = "158.17.201.0/24"
$RG = "VMsRG"
$Location = "West Europe"
$DNS = "15.3.0.0"
$GWName = "GateWay"
$GWIPName = "GateWayIP"
$GWIPconfName = "GateWayIPConfig"
$P2SRootCertName = "XXXXX.cer"
$DeployUserName = "atf@hotmail.com"
$DeployUserPassword = "XXXXX" 

$Azurepwd = ConvertTo-SecureString $DeployUserPassword -AsPlainText -Force
$AzureCredential = new-object -typename System.Management.Automation.PSCredential -argumentlist $DeployUserName, $Azurepwd 
Add-AzureRmAccount -credential $AzureCredential -SubscriptionName Development

New-AzureRmResourceGroup -Name $RG -Location $Location
$fesub = New-AzureRmVirtualNetworkSubnetConfig -Name $SubName -AddressPrefix $SubPrefix
$gwsub = New-AzureRmVirtualNetworkSubnetConfig -Name $GWSubName -AddressPrefix $GWSubPrefix
New-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $RG -Location $Location -AddressPrefix $VNetPrefix1 -Subnet $fesub, $gwsub -DnsServer $DNS

$vnet = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $RG
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet

$pip = New-AzureRmPublicIpAddress -Name $GWIPName -ResourceGroupName $RG -Location $Location -AllocationMethod dynamic

$ipconf = New-AzureRmVirtualNetworkGatewayIpConfig -Name $GWIPconfName -Subnet $subnet -PublicIpAddress $pip

$MyP2SRootCertPubKeyBase64 = "XXXXX"
$p2srootcert = New-AzureRmVpnClientRootCertificate -Name "P2SVNETRootCertName" -PublicCertData $MyP2SRootCertPubKeyBase64
New-AzureRmVirtualNetworkGateway -Name $GWName -ResourceGroupName $RG -Location $Location -IpConfigurations $ipconf -GatewayType Vpn -VpnType RouteBased -EnableBgp $false -GatewaySku Standard -VpnClientAddressPool $VPNClientAddressPool -VpnClientRootCertificates $p2srootcert
Get-AzureRmVpnClientPackage -ResourceGroupName $RG -VirtualNetworkGatewayName $GWName -ProcessorArchitecture Amd64

As I am able to connect using GUI. 因为我能够使用GUI进行连接。 I hope script is doing it's job. 我希望脚本能做到这一点。

After 4 Months I got a reply from MS (as I raised a ticket for the same). 4个月后,我收到了MS的回复(因为我为同一张票出了票)。 They told Rasdial is not supported by Azure VPN Client Package till date. 他们说,到目前为止,Azure VPN客户端程序包不支持Rasdial。 Also, Even after deconstructing-the-azure-point-to-site-vpn lacks addition of route which should be taken care by adding the route explicitly. 同样,即使在解构到站点上的天青点VPN之后,仍然缺少添加路由,应该通过显式添加路由来注意这一点。

So as an workaround I did the steps provided in the blog - http://www.diaryofaninja.com/blog/2013/11/27/deconstructing-the-azure-point-to-site-vpn-for-command-line-usage 因此,作为一种解决方法,我执行了博客中提供的步骤-http: //www.diaryofaninja.com/blog/2013/11/27/deconstructing-the-azure-point-to-site-vpn-for-command-line -用法

However the last part of adding the route is a bit complex. 但是,添加路由的最后一部分有点复杂。 So, for adding route I have created my own PS script- 因此,为了添加路线,我创建了自己的PS脚本-

$Subnet                  = @("10.0.1.0", "10.0.2.0","10.0.3.0")
$VPNClientAddressPool    = "x.x.x"  
$Mask                    = "255.255.0.0"
$azureIpAddress          = ""
$VPNCmd                  = "MYVPNName"

Here xxx are the 3 octet that can be found in "GateWay - Point-to-site configuration" of the VPN- 此处的xxx是3个八位字节,可在VPN-的“网关-点对点配置”中找到

在此处输入图片说明

    $routeExists = route print | findstr $VPNClientAddressPool
    if($routeExists) 
    {         
       route delete $Subnet          
    }

    rasdial $VPNCmd > $null
    $azureIPAddress = ipconfig | findstr $VPNClientAddressPool
    if($azureIPAddress -ne $null)
    {   
        $azureIpAddress = $azureIpAddress.Split(": ")
        $azureIpAddress = $azureIpAddress[$azureIpAddress.Length-1]
        $azureIpAddress = $azureIpAddress.Trim()
        route add $Subnet MASK $Mask $azureIPAddress    
    }   

This solved the purpose for me. 这为我解决了目的。 Basically You just need to take care of the route add part. 基本上,您只需要注意路由添加部分。

Your PowerShell script seems fine (I didn't try the login and resource group pieces, but everything else works from $fesub on.) except for the third line from the bottom. 您的PowerShell脚本看起来不错(我没有尝试登录和资源组的内容,但是其他所有内容都可以从$ fesub开始使用。)除了底部的第三行。 The -Name tag which you currently have as "P2SVNETRootCertName" needs to be the same as your $P2SRootCertName. 当前作为“ P2SVNETRootCertName”使用的-Name标记必须与$ P2SRootCertName相同。 For more information, refer to Azure documentation: https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-howto-point-to-site-rm-ps/ 有关更多信息,请参考Azure文档: https : //azure.microsoft.com/zh-cn/documentation/articles/vpn-gateway-howto-point-to-site-rm-ps/

As for Rasdial, another StackOverflow post has answered this: Azure Virtual Network Point-to-Site (ex. Azure Connect) autoconnect 至于Rasdial,另一个StackOverflow帖子已经回答了这一问题: Azure虚拟网络点对站点(例如Azure Connect)自动连接

-Bridget [MSFT] -Bridget [MSFT]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM