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

使用 netsh 命令列完整掌控 Windows XP 防火牆設定

編輯:XP 系統基礎知識

進入 netsh 防火牆環境

命令提示字元輸入 netsh,提示符變為 netsh>,再輸入 firewall 進入 netsh firewall> 環境。輸入 help 可查看可用指令。

主要指令說明

  • add allowedprogram:新增允許通行的程式
  • add portopening:新增允許通行的連接埠
  • delete:刪除規則
  • show:顯示目前設定
  • set:修改設定
  • reset:重設為預設值
  • dump:匯出設定腳本

新增允許程式語法

add allowedprogram [program=]路徑 [name=]名稱 [mode=]ENABLE|DISABLE [scope=]ALL|SUBNET|CUSTOM [addresses=]IP範圍 [profile=]CURRENT|DOMAIN|STANDARD|ALL

範例:add allowedprogram program="C:\Program Files\Messenger\msmsgs.exe" name="MSN Messenger" mode=ENABLE scope=ALL

新增連接埠開放語法

add portopening [port=]連接埠號 [protocol=]TCP|UDP [name=]名稱 [mode=]ENABLE|DISABLE [scope=]ALL|SUBNET|CUSTOM [addresses=]IP範圍 [profile=]CURRENT|DOMAIN|STANDARD|ALL

範例:add portopening port=80 protocol=TCP name="Web Server" mode=ENABLE

查看與管理

  • show allowedprogram:列出所有允許程式
  • show portopening:列出所有開放連接埠
  • delete allowedprogram program="路徑":移除程式規則
  • delete portopening port=80 protocol=TCP:移除連接埠規則

實戰應用

透過批次檔或遠端命令列,可快速部署防火牆例外規則,適合入侵測試後維持存取、或企業環境自動化佈署。

Copyright © Windows教程網 All Rights Reserved