如何用批处理实现网吧的线路切换

发布时间:2024-05-07 04:15 发布:上海旅游网

问题描述:

我们网吧用的是网通,电信双光纤,我们用的是软路由,有一条线路掉线时路由器会自动切换到另一条线上,我想用批处理做一个手动切换线路的工具,如何实现?

问题解答:

有相应的软件,可以在屏幕上切换

我宿舍既可以上校园网(教育网),也可以上电信ADSL,所以做了个bat文件,情况跟你的要求差不多,上电信的时候IP和DNS都设为自动,亦即是空白;而上教育网的时候则设定IP和DNS,这个你可以改为你的IP和DNS。

@echo off
echo 用于电信ADSL与教育网之间的切换
set s=2
set eth=本地连接
ipconfig /all | find "10.10.33.254" >nul && set s=1
goto n%s%
:n1
echo 教育网-->电信ADSL...
netsh interface ip set address name=%eth% source=dhcp >nul
netsh interface ip set dns name=%eth% source=dhcp register=PRIMARY >nul
goto n3
:n2
echo 电信ADSL-->教育网...
netsh interface ip set address name=%eth% source=static addr=10.10.33.214 mask=255.0.0.0 gateway=10.10.33.254 gwmetric=0 >nul
netsh interface ip set dns name=%eth% source=static addr=202.117.112.3 register=PRIMARY >nul
netsh interface ip add dns name=%eth% addr=218.30.19.40 index=2 >nul
goto n3
:n3
exit
@echo on

自己改吧

热点新闻