`

电脑IP切换工具

阅读更多
@ echo off
rem //设置变量
set Nic=本地连接
rem // 招行内网IP
set Addr=99.1.84.6
set Mask=255.255.255.0
set Gway=99.1.84.253
set Dns1=99.1.34.23
/*set Dns2=99.1.34.23*/
rem //以上依次为IP地址、子网掩码、网关、首选DNS,备用DNS

rem //外网IP
set Addr1=99.1.68.52
set Mask1=255.255.255.0
set Gway1=99.1.68.253
set Dns3=99.1.68.3
//set Dns4=99.1.68.

echo ----------------
echo ---内外-IP切换批处理---
echo ----------------
echo  1  设置为招行内网 IP
echo  2  设置为外网 IP
echo  3  设置为自动获取
echo  4  退出
echo --请选择项目后按下回车
set /p answer=

if %answer%==1 goto 1
if %answer%==2 goto 2
if %answer%==3 goto 3
if %answer%==4 goto 4

:1
echo 正在进行招行内网设置,请稍等...
rem //可以根据你的需要更改
echo. I P 地址 = %addr%
echo. 子网掩码 = %Mask%
echo. 默认网关 = %Gway%
echo. 首选 DNS = %Dns1%
echo. 备用 DNS = %Dns2%
netsh interface ip set address name=%Nic% source=static addr=%addr% mask=%Mask% >nul
netsh interface ip set address name=%Nic% gateway=%Gway% gwmetric=1 >nul
netsh interface ip set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY >nul
netsh interface ipv4 add dnsserver name=%Nic% address=%Dns2%   >nul

echo ----全部设置完成! -----

@Pause
goto end

:2
echo 正在进行招行外网设置,请稍等...
rem //可以根据你的需要更改
echo. I P 地址 = %addr1%
echo. 子网掩码 = %Mask1%
echo. 默认网关 = %Gway1%
echo. 首选 DNS = %Dns3%
netsh interface ip set address name=%Nic% source=static addr=%addr1% mask=%Mask1% >nul
netsh interface ip set address name=%Nic% gateway=%Gway1% gwmetric=1 >nul
netsh interface ip set dns name=%Nic% source=static addr=%Dns3% register=PRIMARY >nul
netsh interface ipv4 add dnsserver name=%Nic% address=%Dns4%  >nul

echo ----全部设置完成! -----
@Pause
goto end

:3
echo 正在进行动态IP设置,请稍等...
echo  I P地址正在从DHCP自动获取...
netsh interface ip set address "本地连接" dhcp
echo  DNS地址正在从DHCP自动获取...
netsh interface ip set dns "本地连接" dhcp
echo ----全部设置完成! ----
@Pause
goto end

:4
echo bye!
goto end
分享到:
评论
Global site tag (gtag.js) - Google Analytics