At my last job I had the option to work from home on occasion but I rarely did it because working over a VPN is a pain. When you connect to a VPN network, by default it disables your local network connection. End result, you can’t check your personal email while connected to the VPN. That was simply not an option for me so a co-worker (Ryan Stille) came up with a genious way to re-route your internet traffic so VPN traffic went through the VPN without disabling your local network. That script looks something like this:
# re-route VPN traffic
route add 10.0.0.0 MASK 255.255.255.0 192.168.1.15 metric 1
The problem with this is that you have to connect to the VPN, then open up a command prompt, find the IP address that was given to you by the VPN and use that instead of “192.168.1.15″.
Here’s some code for a more graceful VBS script that will do the job for you:
Dim ipAddy
ipAddy = GetIPAddress()
If ipAddy <> "" then
FixRouteForRDP(ipAddy)
End If
Function FixRouteForRDP(ipAddy)
set sh = createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")
Set Env = sh.Environment("PROCESS")
workfile = fso.gettempname
sh.run "%comspec% /c route add 10.0.0.0 MASK 255.255.255.0 " & ipAddy & " metric 1"
End Function
Function GetIPAddress()
set sh = createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")
Set Env = sh.Environment("PROCESS")
if Env("OS") = "Windows_NT" then
workfile = fso.gettempname
sh.run "%comspec% /c ipconfig > " & workfile,0,true
else
'winipcfg in batch mode sends output to
'filename winipcfg.out
workfile = "winipcfg.out"
sh.run "winipcfg /batch" ,0,true
end if
set sh = nothing
set ts = fso.opentextfile(workfile)
data = split(ts.readall,vbcr)
ts.close
set ts = nothing
fso.deletefile workfile
set fso = nothing
arIPAddress = ""
for n = 0 to ubound(data)
if instr(data(n), "PPP adapter") then
for m = n to ubound(data)
if instr(data(m),"IP Address") then
parts = split(data(m),":")
if trim(parts(1)) <> "0.0.0.0" then
arIPAddress = trim(cstr(parts(1)))
end if
end if
next
end if
next
If (arIPAddress <> "") then
GetIPAddress = arIPAddress
Else
MsgBox "The VPN does not appear to be connected", vbExclamation, "Error"
GetIPAddress = ""
End IF
End Function
This basically looks up the IP address and runs the route command for you. Note, that in the for loop toward the bottom (if instr(data(n), “PPP adapter”) then), the text “PPP adapter” might need to be replaced by whatever your VPN connection is called. For a basic VPN connection, this should work.
UPDATE: Here’s a step by step on how to handle the networking: http://reynacho.com/2008/11/03/vpn-network-routing-step-by-step/

Related Articles
3 users responded in this post
Nice! I needed this.
Mike Henke was HERE!!!
Nice tools, but it is possible to use in Cisco VPN Client (where split tunnel is disable) ?
Leave A Reply