IP自动设置批处理程序
IP地址自动设置批处理,非常方便,亲测可用!
@ echo off
title IP自动设置程序 - By 何钱伟(Hack0573.com)
rem 设置变量
set Nic=本地连接
rem //可以根据你的需要更改,
set Addr=192.168.0.119
set Mask=255.255.254.0
set Gway=192.168.0.1
set Dns1=220.189.127.106
set Dns2=220.189.127.107
rem //以上依次为IP地址、子网掩码、网关、首选DNS、备用DNS
echo ------------------------------------------------------
echo 正在进行IP设置,请稍等……
rem //可以根据你的需要更改
echo. IP地址 = %Addr%
echo. 子网掩码 = %Mask%
netsh interface ip set address name=%Nic% source=static addr=%Addr% mask=%Mask% >nul
echo. 网关 = %Gway%
netsh interface ip set address name=%Nic% gateway=%Gway% gwmetric=1 >nul
echo. 首选DNS = %Dns1%
netsh interface ip set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY >nul
echo. 备用DNS = %Dns2%
netsh interface ip add dns name=%Nic% addr=%Dns2% index=2 >nul
echo ------------------------------------------------------
echo IP设置完成!
netsh interface ip add dns name=%Nic% addr=%Dns3% index=2 >nul
rem pause >nul
以上是自动设置我们需要配置的ip,那么如果我们要设置成自动获得ip和dns呢?
只需以下两条命令:
netsh interface ip set address name = "本地连接" source = dhcp
netsh interface ip set dns "本地连接" source = dhcp