@ echo off rem 设置变量
set Nic=本地连接
rem //可以根据你的需要更改,
set Addr=192.168.2.81
set Mask=255.255.255.0
set Addr1=192.168.1.81
set Gway=192.168.1.1
set Gway1=192.168.2.254
set Dns1=202.102.192.68
set Dns2=202.102.199.68
rem //以上依次为IP地址、子网掩码、网关、首选DNS、备用DNS
echo ------------------------------------------------------
echo 正在进行IP设置,请稍等
echo. IP地址 = %Addr%
echo. 子网掩码 = %Mask%
echo. 网关 = %Gway%
netsh interface ipv4 set address name=%Nic% source=static addr=%Addr1% mask=%Mask% gateway=%Gway% gwmetric=0 >nul
netsh interface ipv4 add address name=%Nic% addr=%Addr% mask=%Mask% gwmetric=0 >nul
echo. 首选DNS = %Dns1%
netsh interface ip set dns name=%Nic% static %Dns1%
echo. 备用DNS = %Dns2%
netsh interface ip add dns name=%Nic% %Dns2% index=2
echo ------------------------------------------------------
echo IP设置完成!
设为自动获取IP:
Echo off
echo 自动获取IP地址....
netsh interface ip set address name = "本地连接" source = dhcp
echo 自动获取DNS服务器....
netsh interface ip set dns name = "本地连接" source = dhcp
# Echo 自动获取IP成功,按任一键后,就可以使用外网了……
#Pause