Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
在Windows Azure早期版本中,用户要在某台Azure平台之外的机器与Azure平台内部的机器建立专用连接,可以借助Azure Connect这个功能。当前的Azure版本,已经没有Azure Connect功能,取而代之的是Azure P2S (Point-to-Site) VPN. 新的功能P2S VPN较之以前提高了传输速率。但也有一点不足:之前的Azure Connect支持连接断开后的自动重连,而P2S VPN要求用户通过微软拨号软件手动操作VPN的连接/断开。
由于这样那样的原因,P2S VPN有时会断开连接。例如网络的不稳定,操作系统休眠,过多的远程桌面连接等等。如果每一次断开,都需要人工操作来重新连接,那是非常麻烦的。在有些场景中,也是不可接受的。例如两台数据库服务器之间借助VPN进行不间断的数据同步。
下面提供的命令行,可以在Windows机器上实现VPN的自动拨号重连:
rasdial "Your VPN name" /phonebook:%userprofile%\AppData\Roaming\Microsoft\Network\Connections\Cm\Your-VPN\Your-VPN.pbk"
下面是一个例子:
:loop
rasdial TestVN /PHONEBOOK:C:\Users\shiwang\AppData\Roaming\Microsoft\Network\Connections\Cm\TestVN\TestVN.pbk
timeout 120
goto loop
当第一次建立起连接时,该Batch命令的执行结果是:
Connecting to test...
Verifying username and password...
Registering your computer on the network...
Successfully connected to test.
Command completed successfully.
过了2分钟以后,结果是:
You are already connected to test.
Command completed successfully.
如果把这个批处理文件配置成Windows任务,并在开机时启动,就可以实现无需任何人工干预的VPN连接。
Please sign in to use this experience.
Sign in