您的位置:首页 > 其它

快速切换IP的批处理命令

2012-10-11 20:53 309 查看
@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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  interface