网事如风

    网如风,事如风,爱如风,情如风,,,
都随风起,随风去

统计

Microsoft Source

My Friends

My Links

Program

最新评论

如何在不同工作场所切换IP和代理服务器,快速切换环境上网

由于我经常在家和公司使用同一台本本上网,同时也经常到母公司出差,,,经常需要在公司和家都要把IP都设置成自动获取,而到母公司则是设置成固定IP,而到宾馆又把IP设成自动获取的,而且在不同场合的上网代理服务器都要设置不同的,不断的把IP和代理服务器改来改去,真的很是麻烦.特别是公司的那些高层老外,特别不能理解为什么在中国不同的地方上网的方法都不同,而且要改不同的几个东西,写在PDA里都记不住,真是一个头两个大,总是不分时间(有时时差为12/13小时,刚好我还在梦见PPMM咧 ^v^ )地打我电话“hello Bill,Sorry to bother you,but I can't access internet now in xxx.would you pls help me?",,,,,,我,我,我能说“No”吗?他们都是老大唉,,,只能强打精神告诉他们把IP改为xxx,把代理服务器改为xxx就ok了,唉,真是烦啊,,,,为了解脱自己,写了两个脚本,一切搞定,,,,终于可以睡我的安稳觉了,^_^,,,
以下是步骤和脚本:

1,切换IP脚本:net_switch.bat
选择1,退出,
选择2,把IP设成自动获取,在家或宾馆使用
选择3,把IP设成自动获取,DNS改为:172.16.×.×和205.191.×.×,在本地公司使用
选择4,把IP,网关,DNS都改为特定的,在母公司使用

@echo  $###***    Network Switch Tool     ***************************************###$
@echo  *    1--exit;                                                                                                                           *
@echo  *    2--Automatically Network,Use in Apartment and Hotel;                                                  *
@echo  *    3--Local Co. Network,Access  intranet and internet.                                                       *
@echo  *    4--Master Co. Network,Access  intranet and internet.                                                     *
@echo  *                                                                                                                                           *
@echo  **__________________________________________________Bill.lee__Mar 2006___**
@echo off
@choice /c     1234
if errorlevel 4 goto Master
if errorlevel 3 goto GNet
if errorlevel 2 goto autonet
if errotlevel 1 goto end

:Master
@echo  Please wait.....It will be closed automatically when finished....
netsh interface ip set address name="Local Area Connection" static addr=192.1.×.× mask=255.255.255.0 gateway=192.1.×.× 0
netsh interface ip set dns name="Local Area Connection" source=static addr=192.4.×.× register=PRIMARY
netsh interface ip add dns name="Local Area Connection" addr=192.4.×.× index=2
goto end
:GNet
@echo  Please wait.....It will be closed automatically when finished....
netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns name="Local Area Connection" source=static addr=172.16.×.× register=PRIMARY
netsh interface ip add dns name="Local Area Connection" addr=205.191.×.× index=2
goto end
:autonet
@echo  Please wait.....It will be closed automatically when finished....
netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns "Local Area Connection" dhcp
goto end
:end
echo all Set
echo on

2,更换代理服务器脚本:CWAYProxy.PAC
如果本机IP在172.16.*.*网段,把internet代理设为172.16.*.*,端口:8080,否则不使用代理;
我已经删除了在母公司上网使用的代理,请见谅。。。。^_^
使用方法:
1,把以下文件存为文件:D:\Tools\NetWorkSwitch\CWAYProxy.PAC
2,打开ie--工具--选项--连接--本地连接,选择“使用自动配置脚本”,在地址输入:file://D:\Tools\NetWorkSwitch\CWAYProxy.PAC
3,搞定,睡觉,,,,ZZZZZ,,

function FindProxyForURL(url,host){
  if(isInNet(myIpAddress(),"172.16.*.*","255.255.255.0"))
 return "PROXY 172.16.*.*:8080";
  else
 return "DIRECT";

}

3,一些说明:
A,第一个脚本仅适用英文的操作系统,如果是中文系统,相信你很容易改过来,如果还有疑问,请直接联系我:ldqok@hotmail.com
B,脚本中的IP和端口请修改成你所需要的;
C,主要用了netsh命令和FindProxyForURL函数;
D,需要有dos的choice.exe支持,注意区别2000和XP的版本,如果你没有,请发邮件给我:ldqok@hotmail.com

posted on 2007-03-06 11:16 网事如风 阅读(671) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。