- @echo off
- for /f "tokens=16" %%i in ('ipconfig /all ^| find /i "IPv4"') do set ip=%%i
- for /f "tokens=15" %%i in ('ipconfig /all ^| find /i "子网掩码 "') do set mask=%%i
- for /f "tokens=15" %%i in ('ipconfig /all ^| find /i "默认网关"') do set gateway=%%i
- for /f "tokens=14" %%i in ('ipconfig /all ^| find /i "DNS 服务器"') do set dns=%%i
- for /f "tokens=16" %%i in ('ipconfig /all ^| find /i "主机名"') do set name=%%i
- echo 本机IP为:%ip%
- echo 本机子网掩码为:%mask%
- echo 本机网关为:%gateway%
- echo 本机DNS为:%dns%
- echo 主机名为:%name%
- pause
复制代码 但是我的ip是192.168.0.60,获取的是192.168.65.1,而且我获取的dns是一串数字
本机IP为: 192.168.56
本机子网掩码为:255.255.25
本机网关为: 192.168.2.
本机DNS为: fec0:0:0:f
主机名为: KKKK
求解 |