Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows XP 批次檔快速掃描未使用 IP 位址:DHCP 故障排查實用工具

編輯:XP 系統基礎知識

應用場景

網管需找出 DHCP 範圍內哪些 IP 尚未被使用,僅回報可用 IP 並輸出文字檔,避免逐行人工檢視龐大 Ping 結果。

批次檔製作與使用

  1. 記事本建立 IPTracker.bat,內容如下 (單行輸入 For 迴圈):
@Echo off
date /t > IPList.txt
time /t >> IPList.txt
echo =========== >> IPList.txt
For /L %%f in (1,1,100) Do Ping.exe -n 2 192.168.1.%%f | Find "Request timed out." && echo 192.168.1.%%f Timed Out >> IPList.txt && echo off
cls
Echo Finished!
@Echo on
Notepad.exe IPList.txt
  1. 將 192.168.1 替換為實際網段,(1,1,100) 調整為起始、遞增、結束值
  2. 雙擊執行 → 自動掃描 → 以記事本開啟 IPList.txt 僅顯示逾時 (未使用) 的 IP

原理說明

  • For /L %%f in (1,1,100):1 到 100 步進 1 迴圈
  • Ping -n 2:發送 2 個封包加速判斷
  • Find "Request timed out.":篩選無回應 (未使用) 的 IP
  • && 串聯:僅當 Find 成功時記錄 IP 到檔案
限制: 僅適用 Windows XP Professional (Home 版無部分網路指令)。可進階擴充:加入 MAC 位址解析、匯出 CSV、整合進管理腳本等。
Copyright © Windows教程網 All Rights Reserved