@echo off
@color 0a
set Nic="本地连接 2"
set Addr1=192.168.1.166
set Gway1=192.168.1.1
set Addr0=192.168.0.166
set Gway0=192.168.0.1
set Mask=255.255.255.0
set Dns1=8.8.8.8
set Dns2=4.4.4.4
echo 请选择0或1
:change
set /p answer=
if %answer%==1 goto 1
if %answer%==0 goto 0
goto error
:error
echo 输入错误,请输入0或1
goto change
:1
echo 正在配置IP 1,请稍等...
echo name=%Nic%
echo IP地址 = %Addr1%
echo 子网掩码 = %Mask%
echo 网关 = %Gway1%
netsh interface ipv4 set address name=%Nic% source=static addr=%Addr1% mask=%Mask% gateway=%Gway1% gwmetric=0 >nul
echo 首选 DNS = %Dns1%
netsh interface ipv4 set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY >nul
echo 备用 DNS = %Dns2%
netsh interface ipv4 add dns name=%Nic% addr=%Dns2% index=2 >nul
echo ----
echo 全部设置完成!
goto end
:0
echo 正在配置IP 0,请稍等...
echo IP地址 = %Addr0%
echo 子网掩码 = %Mask%
echo 网关 = %Gway0%
netsh interface ipv4 set address name=%Nic% source=static addr=%Addr0% mask=%Mask% gateway=%Gway0% gwmetric=0 >nul
echo 首选 DNS = %Dns1%
netsh interface ipv4 set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY >nul
echo 备用 DNS = %Dns2%
netsh interface ipv4 add dns name=%Nic% addr=%Dns2% index=2 >nul
echo ----
echo 全部设置完成!
goto end
:end
rem pause快速切换IP的批处理命令
最新推荐文章于 2023-05-12 16:59:36 发布
本文提供了一个批处理脚本示例,用于手动配置计算机的网络IP地址、子网掩码、默认网关及DNS服务器。用户可通过简单交互选择不同的配置方案,适用于快速切换网络环境。
563

被折叠的 条评论
为什么被折叠?



