Windows批量配置多ip,Winwows系统批量添加多IP命令行执行脚本bat

迅恒数据中心
@echo off
set "mainip=45.204.82.82"
rem mainip为主IP
set "netmask=255.255.255.0"
rem netmask为主IP对应的子网掩码
set "gateway=45.204.82.254"
rem gateway为主IP对应的网关
set "dns1=223.5.5.5"
set "dns2=14.114.114.114"
rem 上面的2个DNS一般的需要修改,也可以将DNS2修改为8.8.8.8
for /f "tokens=*" %%i in ('wmic nic where "NetConnectionStatus='2'" get NetConnectionID /value^|find "="') do set %%i
set "NetConnectionID=%NetConnectionID%"
for /f "tokens=*" %%i in ('wmic nic where "NetConnectionID='%NetConnectionID%'" get index  /value^|find "="') do set %%i
set "index=%index%"
wmic nicconfig where index="%index%" call enablestatic("%mainip%"),("%netmask%")
wmic nicconfig where index="%index%" call setgateways("%gateway%"),(1)
wmic nicconfig where index="%index%" call SetDNSServerSearchOrder("%dns1%","%dns2%")
wmic nicconfig where index="%index%" call SetTcpipNetbios 2
echo 请注意修改下面IP列表
set "netmask2=255.255.255.0"
rem netmask2为批量增加IP的子网掩码,而且下列IP的子网掩码均相同
for  %%i in (
154.212.144.97
154.212.144.101
45.204.82.103
45.204.82.154
45.204.82.159
45.204.82.207
45.204.82.215
45.204.82.224
45.204.82.232
45.204.82.233
45.204.82.243

) do netsh interface ip add address "%NetConnectionID%"  %%i "%netmask2%" && echo 添加IP%%i成功
pause
exit
以上for  %%i in后的IP一行一个,同时IP的子网掩码相同

分类:教程帮助 百度收录 必应收录