@echo off
rem //设置网卡名称
set NAME="以太网"
rem //以下属性值可以根据需要更改
set ADDR1=192.168.1.143
set ADDR2=192.168.1.143
set MASK=255.255.255.0
set GATEWAY1=192.168.1.1
set GATEWAY2=192.168.1.2
set DNS1=8.8.8.8
set DNS2=114.114.114.114
echo 请输入网络序号:
echo 1 互联网
echo 2 翻墙
echo 3 动态
echo 4 退出
echo 请选择后回车:
choice /c 1234 /n
if %errorlevel%==1 goto 1
if %errorlevel%==2 goto 2
if %errorlevel%==3 goto 3
if %errorlevel%==4 goto 4
:1
echo 正在设置静态IP,请稍等…
netsh interface ipv4 set address name=%NAME% source=static addr=%ADDR1% mask=%MASK% gateway=%GATEWAY1% gwmetric=0 >nul
echo IP地址 = %ADDR1%
echo 掩码 = %MASK%
echo 网关 = %GATEWAY1%
netsh interface ipv4 set dns name=%NAME% source=static addr=%DNS1% register=PRIMARY >nul
echo 首选DNS = %DNS1%
netsh interface ipv4 add dns name=%NAME% addr=%DNS2% index=2 >nul
echo 备用DNS = %DNS2%
echo 静态IP已设置!
pause
goto 4
:2
echo 正在设置静态IP,请稍等…
netsh interface ipv4 set address name=%NAME% source=static addr=%ADDR2% mask=%MASK% gateway=%GATEWAY2% gwmetric=0 >nul
echo IP地址 = %ADDR2%
echo 掩码 = %MASK%
echo 网关 = %GATEWAY2%
netsh interface ipv4 set dns name=%NAME% source=static addr=%DNS2% register=PRIMARY >nul
echo 首选DNS = %DNS2%
netsh interface ipv4 add dns name=%NAME% addr=%DNS1% index=2 >nul
echo 备用DNS = %DNS1%
echo 静态IP已设置!
pause
goto 4
3:
netsh interface ip set address %NAME% dhcp
pause
goto 4
:4
exit
更改网关.rar