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

Win7 綁定 IP 與 MAC 位址防 ARP 攻擊:netsh 取代 arp 指令

編輯:Windows 7 系統介紹

背景

ARP 欺騙攻擊可導致區域網路斷線、資料竊取。傳統用 arp -s IP MAC 靜態綁定,但在 Windows 7 執行會報錯:ARP 項目新增失敗: 請求的作業需要提升 (英文:The ARP entry addition failed: Access is denied.)。微軟確認 Win7 不支援用 arp 新增已存在的綁定。

解決方法:netsh 指令

netsh interface ipv4 set neighbors "介面卡索引" "目標IP" "目標MAC" store=active

範例

netsh interface ipv4 set neighbors 12 "157.55.85.212" "00-aa-00-62-c6-09" store=active
  • 12:網卡介面索引 (需先用 netsh interface ipv4 show interfaces 查詢)。
  • store=active:僅在記憶體生效 (重開機失效);若需永久可用 store=persistent。

查詢介面卡索引

netsh interface ipv4 show interfaces

輸出中 Idx 欄即為索引值,對應介面卡名稱 (如「區域連線」、「無線網路連線」)。

自動化腳本 (登入時執行)

建立 bind_arp.bat 放入「啟動」資料夾:

@echo off
netsh interface ipv4 set neighbors 12 "192.168.1.1" "00-11-22-33-44-55" store=persistent
netsh interface ipv4 set neighbors 12 "192.168.1.254" "aa-bb-cc-dd-ee-ff" store=persistent

綁定閘道 (Router) 與常用伺服器 IP-MAC,有效防禦 ARP 欺騙。

補充

  • 同樣適用於 Windows Vista/8/10/Server 2008+。
  • 若介面卡索引變動 (如增減網卡),需更新腳本索引值。
  • 企業環境建議在交換機層面啟用 DAI (Dynamic ARP Inspection) 或 IP-MAC-Port 綁定,根治 ARP 攻擊。
Copyright © Windows教程網 All Rights Reserved