去评论
随县网_随县论坛_随州随县论坛网

批处理快速设置本地IP、子网掩码、网关、dns服务地址

随县联想电脑
2013/10/12 11:06:42
复制以下代码到记事本另存为“setip.bat”

@ echo off
set Nic=本地连接
set Addr=192.168.1.10
set Mask=255.255.255.0
set Gway=192.168.1.1
set Dns1=202.103.224.68
set Dns2=202.103.225.68

rem //以上依次为IP地址、子网掩码、网关、首选DNS、备用DNS

@echo %Nic%
@echo IP地址 = %Addr%
@echo 子网掩码 = %Mask%
@echo 网关 = %Gway%
@echo 首选DNS = %Dns1%
@echo 备用DNS = %Dns2%
pause

echo 正在进行IP设置,请稍等....
netsh interface ip set address name=%Nic% source=static addr=%Addr% mask=%Mask%
netsh interface ip set address name=%Nic% gateway=%Gway% gwmetric=auto
netsh interface ip set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY
netsh interface ip add dns name=%Nic% addr=%Dns2% index=2

@echo on
@echo IP 已设置
@echo off
pause
exit
家装活动