/www/wwwroot/blog.drearry.com/usr/plugins/AMP/templates/MIPpage.php on line 33
">

Windows 批处理实现一键切换网关

2023-07-03T22:03:00

因为我在主路由上接了一个OpenWrt旁路由,为了不影响主路由,我都是单独将自己的设备网关设置成OpenWrt的地址。这就会出现一个问题,如果我切换了网络环境,就需要更改网关地址。自己手动改太麻烦了,就写了一个脚本自动切换。

@echo off
chcp 65001 > nul 2>&1

echo 网关一键切换

echo 1.DHCP
echo 2 OpenWrt

set/p input_number=请输入数字:
if %input_number% == 1 ( 
    netsh interface ip set address name="wlan" source=dhcp
    netsh interface ip set dns name="wlan" source=dhcp
 ) else if %input_number% == 2 (
    netsh interface ip set address "wlan" static 192.168.28.111 255.255.255.0 192.168.28.221
    netsh interface ip set dns "wlan" static 192.168.28.221 > nul 2>&1
    )
pause
当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »