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

Windows 系統管理員必會的 8 個 DOS 指令:ping、nbtstat、tracert、netstat、nslookup、ipconfig、route、arp

編輯:系統常見問題解答

命令列是排查網路、安全、效能問題的最強利器。精選 8 個高頻指令與實戰參數:

1. ping - 連通性與延遲基準

ping -t 192.168.1.1          # 持續監控,Ctrl+C 停止
ping -l 1472 -f 192.168.1.1  # MTU 測試 (1472+28=1500,-f 禁止分片)
ping -n 1 -w 1000 192.168.1.1 # 單次、1 秒逾時,適合腳本判斷
# TTL 判斷 OS:64 Linux/Unix、128 Windows、254 網路設備

2. nbtstat - NetBIOS 名稱解析與工作群組查詢

nbtstat -A 192.168.1.50      # 查詢 IP 對應 NetBIOS 名稱、MAC、工作群組
nbtstat -a SERVER01          # 查詢名稱對應資訊
nbtstat -n                   # 本機已註冊 NetBIOS 名稱
nbtstat -c                   # NetBIOS 名稱快取
# 適用 Windows 工作群組環境、舊版相容性排查

3. tracert / traceroute - 路徑追蹤與瓶頸定位

tracert 8.8.8.8              # Windows
traceroute -I 8.8.8.8        # Linux/macOS (ICMP 模式)
# 觀察:第幾跳延遲暴增/丟包 → 該段鏈路/設備異常
# * * * 表示該跳不回應 ICMP (防火牆/設定),不一定斷線

4. netstat - 連線/埠口/協定統計

netstat -ano                 # 所有連線 + PID
netstat -ano | findstr :80   # 找佔用 80 埠的 PID
netstat -r                   # 路由表
netstat -s                   # 協定統計 (TCP/UDP/ICMP/IP 封包計數)
netstat -e                   # 介面統計 (位元組/封包/錯誤/捨棄)

5. nslookup / dig - DNS 解析除錯

nslookup example.com         # 互動模式
nslookup -type=mx example.com # 查 MX 記錄
nslookup example.com 8.8.8.8  # 指定 DNS 伺服器
# Linux 推薦 dig:
dig +short example.com A
dig @1.1.1.1 example.com MX +noall +answer

6. ipconfig / ifconfig - 介面設定檢視

ipconfig /all                # 完整資訊 (MAC、DHCP 租約、DNS 伺服器)
ipconfig /displaydns         # DNS 快取內容
ipconfig /flushdns           # 清除 DNS 快取
ipconfig /release && ipconfig /renew  # 重新取得 DHCP 租約

7. route - 路由表操作

route print                  # 完整路由表 (IPv4/IPv6)
route add 10.0.0.0 mask 255.0.0.0 192.168.1.254  # 新增靜態路由
route delete 10.0.0.0        # 刪除
route -p add ...             # 永久路由 (重開機保留)

8. arp - 位址解析協定快取

arp -a                       # 顯示 IPv4-對應 MAC 表
arp -d 192.168.1.50          # 刪除特定條目 (排查 IP 衝突/ARP 欺騙)
arp -s 192.168.1.50 00-11-22-33-44-55  # 靜態綁定 (防 ARP Spoofing)

實戰組合拳

  • 網路不通:ipconfig /all → ping 閘道 → ping 8.8.8.8 → tracert 8.8.8.8 → nslookup google.com
  • 埠口衝突:netstat -ano | findstr :8080 → tasklist | findstr → taskkill /PID /F
  • ARP 欺騙檢測:arp -a 檢查閘道 IP 是否對應多筆 MAC、或 MAC 廠商代碼異常。

熟練這 8 指令,網路、安全、效能問題 80% 可在命令列完成定位。

Copyright © Windows教程網 All Rights Reserved