Win批处理开机如何自动设置IP地址
@echo off
REM select=1,网卡IP将被设置成172.16.200.34,select=2,网卡IP将被设置成192.168.0.5
ping -n 2 192.168.0.254 && set select=2 || set select=1
REM 获取网卡名称
for /f "skip=4 tokens=3* delims= " %%i in ('ipconfig') do (
set adapter=%%i
goto out
)
:out
set adapter=%adapter::=%
if %select%==1 (
netsh int ip set address name="%adapter%" static 172.16.200.34 255.255.255.0 172.16.200.1 1
netsh int ip set dns name="%adapter%" static 202.102.224.68 primary
netsh int ip add dns name="%adapter%" 202.102.227.68 index=2
) else (
netsh int ip set address name="%adapter%" static 192.168.0.5 255.255.255.0 192.168.0.254 1
)
echo 设置完成,按任意键退出!
pause >nul 2>nul
REM select=1,网卡IP将被设置成172.16.200.34,select=2,网卡IP将被设置成192.168.0.5
ping -n 2 192.168.0.254 && set select=2 || set select=1
REM 获取网卡名称
for /f "skip=4 tokens=3* delims= " %%i in ('ipconfig') do (
set adapter=%%i
goto out
)
:out
set adapter=%adapter::=%
if %select%==1 (
netsh int ip set address name="%adapter%" static 172.16.200.34 255.255.255.0 172.16.200.1 1
netsh int ip set dns name="%adapter%" static 202.102.224.68 primary
netsh int ip add dns name="%adapter%" 202.102.227.68 index=2
) else (
netsh int ip set address name="%adapter%" static 192.168.0.5 255.255.255.0 192.168.0.254 1
)
echo 设置完成,按任意键退出!
pause >nul 2>nul
相关推荐
shenghua 2013-03-27
happygongzhuo 2008-09-04
smalllove 2020-11-03
wuhuaguwuhuaguo 2020-09-15
guying 2020-08-16
wqcong 2020-06-14
chenzhiwei 2020-06-13
talkingDB 2020-05-05
83206837 2020-05-01
Yasin 2020-03-03
Amzaing00 2020-01-06
GechangLiu 2020-01-05
文山羊 2019-12-16
乾坤一碼農 2019-12-11
dongxurr 2019-12-09
bluestartlxp 2019-11-27
86427217 2015-04-18
thankinglove 2015-09-06
圆圆的世界CSDN 2019-11-07