- @echo off&setlocal ENABLEDELAYEDEXPANSION
- set 网卡=本地连接
- set ip1=192.168.0.1
- set mask1=255.255.255.0
- set Gateway1=192.168.0.10
- set ip2=31.18.1.10
- set mask2=255.0.0.0
- set Gateway2=31.18.1.10
- set dns=61.177.7.1
- for /f "tokens=3" %%i in ('netsh interface ip show address %网卡%^|findstr /i /c:"IP 地址"') do if %%i==%ip1% (set i=2) else (set i=1)
- netsh interface ip set address %网卡% static !ip%i%! !mask%i%! !Gateway%i%! 1
- netsh interface ip set dns name="%网卡%" source=static addr=%dns%
复制代码
|