Windows用脚本快速修改IP地址(Netsh)


 

【创建文本文件,改后缀为.bat】

dormitory.bat :

netsh interface ip set address "本地连接" static 10.16.17.194 255.255.255.0 10.16.17.254 1

laboratory.bat :

netsh interface ip set address "本地连接" static 10.18.46.111 255.255.255.0 10.18.46.254 1
 
wireless.bat :
 
netsh interface ip set address name="本地连接" source=dhcp
 

这样就设置了本地 IP / Mask / GateWay

如果是固定IP,还需要要添加DNS服务器方法【可添加多个】:

netsh interface ip add dns name = "本地连接" addr = 61.155.18.30
netsh interface ip add dns name = "本地连接" addr = 8.8.8.8

清空DNS服务器的方法:

rem 清空DNS 
netsh interface ip set dns name = "本地连接" static addr = none 

使用dhcp自动分配ip的快捷netsh命令:

netsh interface ip set address name="本地连接" source=dhcp

为一个网络连接设置二个或多个IP地址:

netsh interface ip set address name="本地连接" source=static addr=66.11.12.12 mask=255.255.255.0
netsh interface ip add address name="本地连接" addr=100.100.100.105 mask=255.255.255.0
netsh interface ip add address name="本地连接" addr=192.168.2.243 mask=255.255.255.0
 

 

posted on 2013-05-21 09:31  JohnChain  阅读(852)  评论(0编辑  收藏  举报

导航