tel8618217223380 / chnroutes

Automatically exported from code.google.com/p/chnroutes
0 stars 0 forks source link

Windows vpnup.bat 改进建议 #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
根据现在的设计,必须要先运行vpnup.bat,再打开vpn,否则local
 gateway会有问题。而且不能像autoproxy一样临时开关。

下面的代码在windows7下对pptp/l2tp/openvpn测试过了。

由于运行时间较长,建议用 -p 
将路由表存在注册表中。同时,另外给一个batch,专门清空路
由表 route -f。

@echo off
chcp 437
for /F "tokens=1,2,3" %%X  in ('route print ^| findstr "\<0.0.0.0\>"') do if 
'%%X' == '0.0.0.0' if '%%Y' == '0.0.0.0' if not '%%Z' == 'On-link' set gw=%%Z

if not %gw% == '' goto :setroute
echo error: fail to find the local gateway
pause
exit /b

:setroute
route -p add 1.0.1.0 mask 255.255.255.0 %gw% metric 5
... ...

Original issue reported on code.google.com by dixiatie...@gmail.com on 17 Mar 2012 at 6:54

GoogleCodeExporter commented 9 years ago
cmroute.dll那个更快

Original comment by Numb.Maj...@gmail.com on 24 Jul 2012 at 6:27