设置PPTP VPN优先使用远程DNS

由于微软在定义接口的时候,本地连接的接口优先顺序被绑定在前面,这样,即使连接上PPTP VPN也无法解决DNS污染问题(及时PPTP服务器在国外且使用8.8.8.8或者openDNS),只能解决封锁IP的问题,解决的办法也简单,在本地连接中指定8.8.8.8 或者删除本地连接的DNS设定即可
对于一般人,这样做就够了
但是对于我来说,还远远不够
身处教育网内部,我们的网络环境非常复杂,首先,我们学校有自己的DNS,且主网站做了DNS负载均衡,校内用户直接解析到内网IP上,而校外电信用户的DNS解析的时候就解析到电信IP的DNS负载均衡设备上,如果我在校内使用外面的DNS,比如google的DNS,就会导致学校主网站被解析到电信IP,触发计费系统,导致无法访问内网资源,而每次切换本地连接的配置又非常麻烦,于是找原因和解决方案,终于找到了

SEE:http://www.hideipvpn.com/2009/09/dns-issues-on-pptp-vpn-connect/

微软知识库:http://support.microsoft.com/kb/311218/zh-cn

除了微软提到的手工方案,这里有个VBS脚本可以解决这个问题

[text]' KB311218 - Cannot Change the Binding Order for Remote Access Connections
' ========================================================================
' VBScript that places the \Device\NdisWanIp entry on the top in the
' registry value Bind (multi-string) that is found under the key
' HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage\.
' If the entry already is at the top, no registry update is done.

Const HKLM = &H80000002

sComputer = "." ' use "." for local computer

' Connect to WMI's StdRegProv class
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& sComputer & "\root\default:StdRegProv")

' Define registry location
sKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Linkage"
sValueName = "Bind"

oReg.GetMultiStringValue HKLM, sKeyPath, sValueName, arValues

arValuesNew = Array()

For i = 0 To UBound(arValues)
If i = 0 Then
If LCase(arValues(i)) = "\device\ndiswanip" Then
' Entry is already first in the list, no point in continuing
Exit For
Else
' Put NdisWanIp in the first element in the new array
ReDim Preserve arValuesNew(0)
arValuesNew(0) = "\Device\NdisWanIp"
End If
End If

' Continue adding the rest of the elements to the new array
If LCase(arValues(i)) <> "\device\ndiswanip" Then
iCountNew = UBound(arValuesNew) + 1
ReDim Preserve arValuesNew(iCountNew)
arValuesNew(iCountNew) = arValues(i)
End If
Next

' If there are elements to be found in the array, update the
' registry value
If UBound(arValuesNew) > -1 Then
oReg.SetMultiStringValue HKLM, sKeyPath, sValueName, arValuesNew
End If
[/text]

点此下载:
[download id="16" format="2"]
每次VPN连通/断开时,都不需要重新运行,除非你新增加或者删除了接口,包括网卡驱动重装/建立新VPN连接等~。

Author Info :
  • From:设置PPTP VPN优先使用远程DNS
  • URL:https://blog.ihipop.com/2010/06/1284.html
  • Please Reserve This Link,Thanks!
  • 《设置PPTP VPN优先使用远程DNS》上有4条评论

    发表回复

    您的电子邮箱地址不会被公开。 必填项已用 * 标注