如何用cmd 辨别真伪ip地址 net com
发布网友
发布时间:2022-04-30 14:21
我来回答
共1个回答
热心网友
时间:2022-06-23 01:53
@echo off
set "ip1=^10$ ^172$ ^192$"
set "ip2=^2[0-5][0-5]$ ^1[0-9][0-9]$ ^[1-9][0-9]$ ^[0-9]$"
set "ip3=^2[0-5][0-4]$ ^1[0-9][0-9]$ ^[1-9][0-9]$ ^[1-9]$"
set "ip4=^1[6-9]$ ^2[0-9]$ ^3[0-1]$"
:ip
cls
set/p ip=请输入IP(如:192.168.1.1)
echo %ip%|findstr "^[0-9]*.[0-9]*.[0-9]*.[0-9]*$">nul||pause&&goto :ip
for /f "tokens=1,2,3,4 delims=." %%i in ("%ip%") do (
echo %%i|findstr "%ip1%">nul||goto :ip
echo %%k|findstr "%ip2%">nul||goto :ip
echo %%l|findstr "%ip3%">nul||goto :ip
if %%i==10 echo %%j|findstr "%ip2%">nul||goto :ip
if %%i==172 echo %%j|findstr "%ip4%">nul||goto :ip
if %%i==192 echo %%j|findstr "^168$">nul||goto :ip
)
echo 正确IP地址
pause>nul
goto :ip