thumbnail

每次切换爱快和op的网关太费劲了,搞个bat点两下切换。

切换到爱快10.0.0.1的时候dhcp自动获取就好了,op那边的dns还是加了个opendns,ipv6也禁用掉,避免因为只有v4的代理导致网站走v6打不开。

@echo off
mode con cols=30 lines=15
:menu
cls
echo.
echo 切换网关:
echo.
echo 输入1切换到10.0.0.1
echo.
echo 输入2切换到10.0.0.2
echo.
echo 输入3取消切换
echo.
set /p choice=输入选项: 
if "%choice%"=="1" (
    cls
    echo.
    echo 正在切换到10.0.0.1
    netsh interface ip set address name="以太网" source=dhcp>nul
    netsh interface ip set dns name="以太网" dhcp >nul
    Powershell -command " Enable-NetAdapterBinding -Name "以太网" -ComponentID ms_tcpip6 "
    exit
) else if "%choice%"=="2" (
    cls
    echo.
    echo 正在切换到10.0.0.2
    netsh interface ip set address name="以太网" static 10.0.0.6 255.0.0.0 10.0.0.2>nul
    netsh interface ip add dns name="以太网" addr=10.0.0.1 >nul
    netsh interface ip add dns name="以太网" addr=208.67.222.222 >nul
    Powershell -command " Disable-NetAdapterBinding -Name "以太网" -ComponentID ms_tcpip6 "
    exit
) else if "%choice%"=="3" (
    cls
    echo.
    echo 切换已经取消
    timeout /t 2 >nul
    exit
) else (
    cls
    echo.
    echo 重试
    timeout /t 1 >nul
    goto menu
)

有什么办法能够无缝切换呢,每次从手动设置的配置切换到自动获取时,不会掉线,但是反过来切换就会掉线一会儿,难受。