網管排查 DHCP 衝突需找出網段內未使用 IP。單純 ping 迴圈輸出太多資訊,批次檔過濾僅顯示逾時 (未使用) IP 並記錄至檔案。
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
IPTracker.bat (編碼 ANSI)。IPList.txt 並用記事本開啟。Ping -n 2 僅送 2 封封包加速。Find "Request timed out." 過濾無回應 (未使用) IP。findstr/完整 for 支援)。一次製作,長期使用,大幅提升 DHCP 故障排查效率。