不同网段间的切换脚本

经常在网段之间频繁切换,要重新设置IP,DNS服务器,代理地址实在是麻烦,

使用脚本会方便很多。

 

1、IP,DNS服务器切换脚本

192.168.20.77.bat
1 netsh interface ip set address local static 192.168.20.77 255.255.255.0 192.168.20.254 1
2
3 netsh interface ip set dns name="local" source=static addr=192.168.2.242 register=PRIMARY
4
5 netsh interface ip add dns name="local" addr=192.168.10.242 index=2
192.168.1.50.bat
1 netsh interface ip set address local static 192.168.1.50 255.255.255.0 192.168.1.1 1
2
3 netsh interface ip set dns name="local" source=static addr=192.168.1.1 register=PRIMARY

 

2、代理自动配置脚本

 如果在不同网段使用的不同的代理,可使用代理的自动配置脚本。

proxy.pac
function FindProxyForURL(url,host)
{

if(myIpAddress()=="192.168.20.77")
{
return "PROXY 192.168.2.250:80";
}

if(myIpAddress()=="192.168.1.50")
{
return "PROXY 192.168.1.254:8080";
}

return "direct";
}






 

 

posted @ 2011-10-12 10:42  子扬  阅读(814)  评论(0编辑  收藏  举报