其实就是分享一个脚本,分别是更改为指定IP和更改为自动获取
有时候我们一台机器进行测试,往往要把IP切换来切换去,手动切换麻烦要死,而且还容易出错
直接使用该脚本可以带来很大的方便
更改为指定IP:
@echo off
echo 正在更换为您的IP为192.168.0.172,请稍侯......
netsh interface ip set address name="本地连接" source=static addr=192.168.0.172 mask=255.255.255.0
echo 设置IP为192.168.0.172,子网掩码为255.255.255.0
netsh interface ip set address name="本地连接" gateway=192.168.0.1 gwmetric=0
echo 设置网关为192.168.0.1
netsh interface ip set dns name="本地连接" source=static addr=202.106.196.115 register=PRIMARY
echo 设置首选DNS为202.106.196.115
::netsh interface ip add dns name="本地连接" addr=202.106.196.115
::设置备用DNS为202.106.196.115
echo 已经成功设置为192.168.0.172
echo ----------------------------------------
ipconfig /all
pause
exit
更改为自动获取:
@echo off
rem eth //设置网卡名称,如"本地连接"
set eth="本地连接"
rem sleep //设置后面的等待时间,如"20秒"
set sleep=ping -n 20 127.0.0.1>nul 2>nul
echo 正在更改为自动获取IP地址...
netsh interface ip set address "%eth%" source=dhcp
echo 正在更改为自动获取DNS地址...
netsh interface ip set dns "%eth%" source=dhcp
echo ----------------------------------------
ipconfig /all
pause
close
请您到ITEYE网站看 java小强 原创,谢谢!
http://cuisuqiang.iteye.com/ !
自建博客地址:http://www.javacui.com/ ,内容与ITEYE同步!