@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