| mark.stradling@gmail.com 2007-06-13, 7:13 pm |
|
'=======================================
===================================
'
' VBScript Source File -- Created with SAPIEN Technologies
PrimalScript 4.1
'
' NAME: Microsoft PPTP Split Tunnel Fix
'
' AUTHOR: Mark Stradling (mark_stradling@hotmail.com)
' DATE : 6/13/2007
'
' COMMENT: When using Micro$oft PPTP VPN - if you disable "use default
gateway on remote network"
' you are then unable to route traffic to any network other than the
subnet defined by your
' VPN IP address. To get around this, run this script after connecting
to VPN.
'
' How it works
' This script checks the systems IP address. It identifies the VPN IP
by matching
' the first 3 octets. After determining the assigned VPN IP address it
then adds
' windows routing table entries that point the routing table to locate
specified
' subnets by using the assigned VPN IP address.
' It is necessary to find the VPN IP address first as this should be
' the gateway for subnets on the other side of the VPN tunnel
'=======================================
===================================
strComputer = "."
Set objRegEx1 = New RegExp
'---------------
' # Start here: Replace the value after .Pattern with the first 3
octets of the VPN Pool
' # Example: VPN Pool is 10.10.10.1 - 10.10.10.254 = enter 10.10.10.
in place of 172.16.16.
'---------------
With objRegEx1
..Pattern = "172.16.16."
..IgnoreCase = True
..Global = True
End With
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled
= True")
For Each objItem in colItems
For Each strAddress in objItem.IPAddress
varMatch = objRegEx1.test(strAddress)
If varMatch Then
strVPNIP = straddress
Else
End If
Next
Next
Set wshShell = CreateObject("WScript.Shell")
strRouteAdd = "Route add"
'----------------------------------------------------
'# Enter the networks you would like to route to through the VPN
tunnel
'# Copy the syntax used below
'# Example: If you wanted to route to 10.10.0.0 255.255.0.0 through
the VPN enter
'# strNet4 = "10.10.0.0 mask 255.255.0.0"
'# increment strNet# for each new network
'----------------------------------------------------
strNet1 = "192.168.2.0 mask 255.255.255.0"
strNet2 = "192.168.65.0 mask 255.255.255.0"
strNet3 = "192.168.12.0 mask 255.255.255.0"
'----------------------------------------------------
'# For each entry above - create a matching entry of the one below
'# You may copy and paste - just make sure to modify the strNet# value
'# to match with each network you added above
'# Example: To add the network used in previous example type
'# wshShell.Run(strRouteAdd & " " & strNet4 & " " & strVPNIP)
'# NOTE: I add strNet4 to match my strNet4 entry made above
'----------------------------------------------------
wshShell.Run(strRouteAdd & " " & strNet1 & " " & strVPNIP)
wshShell.Run(strRouteAdd & " " & strNet2 & " " & strVPNIP)
wshShell.Run(strRouteAdd & " " & strNet3 & " " & strVPNIP)
WScript.Quit
|