@echo off
cls
echo.
rem 新区ip配置
rem ip //设置IP地址
set ip1=10.13.40.60
rem gw //设置网关
set gw1=10.13.40.1
rem netmasks //设置子网掩码
set netmasks1=255.255.254.0
rem 老区ip配置
rem ip //设置IP地址
set ip2=192.168.1.123
rem gw //设置网关
set gw2=192.168.1.1
rem netmasks //设置子网掩码
set netmasks2=255.255.255.0
rem 宿舍ip配置
rem ip //设置IP地址
set ip3=192.168.1.123
rem gw //设置网关
set gw3=192.168.1.1
rem netmasks //设置子网掩码
set netmasks3=255.255.255.0
rem dns1 //设置主DNS
set dns1=61.147.37.1
rem dns2 //设置辅DNS
set dns2=61.177.7.1
set eth=本地连接
:MENU
echo.
echo 新区设置请按-1
echo.
echo 老区设置请按-2
echo.
echo 宿舍默认请按-3
echo.
echo 自动获取请按-4
echo.
echo 察看状态请按-5
echo.
echo.
set /p KEY= 请输入您的选择:
if %KEY% == 1 goto 新区
if %KEY% == 2 goto 老区
if %KEY% == 3 goto 宿舍
if %KEY% == 4 goto DHCP
if %KEY% == 5 goto LOOK
goto END
:LOOK
echo.
ipconfig
echo.
echo 本程序默认修改的是“本地连接”的设置
echo.
echo 需要修改请按相应的数字键,
echo.
echo 例如:输入2表示改为“本地连接 2”
echo.
set /p INTEMP= [请输入本地连接的编号]
if %INTEMP% == 1 set eth=本地连接
if %INTEMP% == 2 set eth=本地连接 2
if %INTEMP% == 3 set eth=本地连接 3
if %INTEMP% == 4 set eth=本地连接 4
if %INTEMP% == 5 set eth=本地连接 5
cls
goto MENU
:新区
echo 正在将本机IP更改到:%ip1%
netsh interface ipv4 set address "%eth%" static %ip1% %netmasks1% %gw1%
echo 正在添加本机主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1% primary
echo 正在添加本机副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo IP更改完毕,检查当前配置...
echo ------------------------------
ipconfig /all
pause
goto end
:老区
@echo off
echo 正在将本机IP更改到:%ip2%
netsh interface ipv4 set address "%eth%" static %ip2% %netmasks2% %gw2%
echo 正在添加本机主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1% primary
echo 正在添加本机副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo IP更改完毕,检查当前配置...
echo ------------------------------
ipconfig /all
pause
goto end
:宿舍
@echo off
echo 正在将本机IP更改到:%ip3%
netsh interface ipv4 set address "%eth%" static %ip3% %netmasks3% %gw3%
echo 正在添加本机主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1% primary
echo 正在添加本机副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo IP更改完毕,检查当前配置...
echo ------------------------------
ipconfig /all
pause
goto end
:DHCP
echo 正在将本机IP更改为自动获取:
netsh interface ipv4 set address "%eth%" dhcp
echo 正在添加本机主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1% primary
echo 正在添加本机副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo IP更改完毕,检查当前配置...
echo ------------------------------
ipconfig /all
pause
goto end
:end
pause
联系客服