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

解決 Windows 作業系統 DHCP 故障的批次檔技巧

編輯:Windows XP 系統介紹

在排解 Windows DHCP 故障時,常需找出某 IP 範圍內未被使用的位址。只需建立一個批次檔,讓它只回傳未使用的 IP,並將結果輸出至文字檔即可。

身為網管人員,我們常需在 DHCP 故障排除中找出某範圍內的閒置 IP。過去介紹過在命令提示字元用 For /L %f in (1,1,100) Do Ping.exe -n 2 192.168.1.%f,但這會列出所有 IP(含在用與未用),得在大量輸出中人工篩選。其實我們可以寫批次檔,只輸出未使用的 IP 並存檔。

方法如下:

開啟記事本,輸入以下指令:

@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,關閉記事本。

注意:批次檔中整個 For…In…Do 指令由數個用 && 串連的指令組成,必須寫在同一行,以 For 開頭、Off 結尾。使用時請將範例 IP 換成你自己的網段。

日後遇到 DHCP 問題,在瀏覽器視窗中雙擊 IPTracker.bat 即可啟動 IP 追蹤工具,它只尋找未使用的 IP 並將結果存入記事本檔案(此批次檔可重複使用)。

注意:此方法僅適用於 Windows XP Professional(專業版)。

Copyright © Windows教程網 All Rights Reserved