批处理更换ip地址

@echo off
echo  设置IP地址
echo正在设置IP地址和子网掩码.
netsh interface ip set address name="本地连接" source=static addr=192.168.0.2 mask=255.255.255.0
echo设置网关
netsh interface ip set address name="本地连接" gateway=192.168.0.1 gwmetric=0

echo 设置首选DNS1
netsh interface ip set address name="本地连接" source=static addr=192.168.0.3 register=primary
echo 设置备用DNS2,如果没有此行代码删除掉
netsh interface ip add dns name="本地连接"  addr=192.168.0.4

netsh interface ip set wins name="本地连接" source=static addr=none

 

 

 

@echo off
echo 设置自动获得ip地址
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip set dns name="本地连接" source=dhcp

posted @ 2012-08-14 15:52  ike_li  阅读(215)  评论(0编辑  收藏  举报