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

Windows XP 批次檔檢測區域網路 IP 連通性實作

編輯:Windows XP 系統介紹

Windows XP 區域網路環境下,需快速檢測特定網段 IP 連通性。透過批次檔自動化 Ping 掃描,僅記錄無回應 IP,高效識別可用位址與網路故障點。

批次檔完整程式碼 (PingIP.bat)

@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.0.%%f | Find "Request timed out." & echo 192.168.0.%%f Timed Out >> IPList.txt & echo off
cls
Echo Finished!
@Echo on
Notepad.exe IPList.txt

執行流程

  1. 記錄執行日期時間至 IPList.txt
  2. 迴圈掃描 192.168.0.1 ~ 192.168.0.100
  3. 每 IP 發送 2 個 ICMP 封包 (-n 2)
  4. Find "Request timed out." 過濾無回應
  5. 無回應 IP 記錄至 IPList.txt
  6. 完成自動開啟記事本顯示結果

關鍵修改點

  • 網段修改:將 192.168.0 替換為實際環境網段(如 10.0.1、172.16.5)
  • 掃描範圍:修改 (1,1,100) 起始、遞增、結束值
  • 封包數:-n 2 可改為 -n 1 加速或 -n 4 提高可靠度

限制與注意

  • 僅適用 Windows XP(Win7/10 指令語法略異,需調整)
  • 目標主機啟用防火牆封鎖 ICMP 會被誤判為離線
  • 無法偵測 ARP 層面衝突/重複 IP
  • 大範圍掃描耗時較長,建議分段執行

應用場景

  • DHCP 伺服器故障時,快速尋找可用靜態 IP
  • 網路擴充規劃,盤點現有 IP 使用狀態
  • 安全稽核,發現未授權裝置(配合 MAC 地址對照)
  • 網路故障排除,確認特定網段連通性

掌握批次檔 Ping 掃描技巧,讓 Windows XP 成為得力的網路偵測工具,無需安裝額外軟體即可完成專業級 IP 盤點。

Copyright © Windows教程網 All Rights Reserved