文章編號: 947709 - 上次校閱: 2012年3月6日 - 版次: 0.1

如何使用 「 netsh advfirewall 防火牆 」 內容,而不是 「 netsh 防火牆 」 內容的控制 Windows Server 2008 中,並在 Windows Vista 中的 Windows 防火牆行為

系統提示本文適用於您使用的作業系統之外的作業系統。與您不相關的文章內容已停用。

在此頁中

全部展開 | 全部摺疊

簡介

[ netsh advfirewall 防火牆 命令列的內容可供使用和 Windows Server 2008 中Windows Vista。本文中提供的功能控制視窗防火牆由所提供的行為 netsh 防火牆 在舊版 Windows 作業系統中的內容。

這內容也會提供功能的防火牆規則更精確的控制。這些規則包括下列每個設定檔設定值:
  • 網域
  • 私用
  • 公用
[ netsh 防火牆 指令行內容可能會在未來的版本中已被取代Windows 作業系統中。我們建議您使用 netsh advfirewall 防火牆 若要控制的防火牆行為的內容。

附註 Netsh 防火牆命令列並不適用於使用中Windows Vista。

本文將告訴您如何使用 netsh advfirewall 防火牆 而不是內容 netsh 防火牆 內容控制在 Windows Server 中的 Windows 防火牆行為2008 與 Windows Vista 中。

其他相關資訊

重要 如果您是系統管理員 」 群組的成員,而且是使用者帳戶控制在您的電腦上啟用,從命令提示字元執行命令提高權限。若要以提高權限啟動命令提示字元,請找出該圖示或 [開始] 功能表項目,您用來啟動命令提示字元工作階段中,以滑鼠右鍵按一下,然後按一下 以管理員身分執行.

提供一些常用命令的範例下表中。您可以使用這些範例,來幫助您從移轉較舊 netsh 防火牆 到新的內容 netsh advfirewall 防火牆 內容。

此外, netsh advfirewall 您可以使用來取得詳細的內嵌幫助的命令所提供。

範例 1: 啟用程式

摺疊此表格展開此表格
舊的命令新的命令
netsh 防火牆新增 allowedprogram C:\MyApp\MyApp.exe 「 我的應用程式 」 啟用netsh advfirewall 防火牆新增規則名稱 ="我的應用程式"dir = 作用中 = 允許 program="C:\MyApp\MyApp.exe"啟用 = 是
netsh 防火牆中加入 allowedprogram program=C:\MyApp\MyApp.exe 名稱 = [我的應用程式] 模式 = 啟用領域 = 自訂 addresses=157.60.0.1,172.16.0.0/16,LocalSubnet 設定檔: 網域netsh advfirewall 防火牆新增規則名稱 ="我的應用程式"dir 作用中 = = 允許程式 ="C:\MyApp\MyApp.exe" 啟用 = [是] remoteip=157.60.0.1,172.16.0.0/16,LocalSubnet 設定檔: 網域
netsh 防火牆中加入 allowedprogram program=C:\MyApp\MyApp.exe 名稱 = [我的應用程式] 模式 = 啟用領域 = 自訂 addresses=157.60.0.1,172.16.0.0/16,LocalSubnet 設定檔 = 全部請執行下列命令:

netsh advfirewall 防火牆新增規則名稱 ="我的應用程式" dir 作用中 = = 允許程式 ="C:\MyApp\MyApp.exe" 啟用 = [是] remoteip=157.60.0.1,172.16.0.0/16,LocalSubnet 設定檔: 網域

netsh advfirewall 防火牆新增規則名稱 ="我的應用程式" dir 作用中 = = 允許程式 ="C:\MyApp\MyApp.exe" 啟用 = [是] remoteip=157.60.0.1,172.16.0.0/16,LocalSubnet 設定檔 = 私用
如需有關如何新增防火牆規則的詳細資訊,請執行下列命令:
netsh advfirewall 防火牆新增規則嗎?

範例 2: 啟用連接埠

摺疊此表格展開此表格
舊的命令新的命令
netsh 防火牆新增 portopening TCP 80 "開啟連接埠 80"netsh advfirewall 防火牆新增規則名稱 ="開啟連接埠 80" dir 作用中 = = 允許通訊協定 = TCP localport = 80
如需有關如何新增防火牆規則的詳細資訊,請執行下列命令:
netsh advfirewall 防火牆新增規則嗎?

範例 3: 刪除已啟用的程式或連接埠

摺疊此表格展開此表格
舊的命令新的命令
netsh 防火牆刪除 allowedprogram C:\MyApp\MyApp.exenetsh advfirewall 防火牆刪除規則名稱 =規則名稱 程式 ="C:\MyApp\MyApp.exe"
刪除 portopening 通訊協定 = UDP 連接埠 = 500netsh advfirewall 防火牆刪除規則名稱 =規則名稱 通訊協定 = udp localport = 500
如需有關如何刪除 [防火牆規則的詳細資訊,請執行下列命令:
netsh advfirewall 防火牆刪除規則嗎?

範例 4: 設定的 ICMP 設定值

摺疊此表格展開此表格
舊的命令新的命令
netsh 防火牆設定 icmpsetting 8netsh advfirewall 防火牆新增規則名稱 ="ICMP 允許連入 V4 回應要求" 通訊協定 = icmpv4:8,任何 dir 作用中 = = 允許
netsh 防火牆設定 icmpsetting 類型 = 所有模式都私人網路netsh advfirewall 防火牆新增規則名稱 ="所有 ICMP V4" 通訊協定 = icmpv4: 任何,任何 dir 作用中 = = 允許
netsh 防火牆設定所有的 icmpsetting 13 停用netsh advfirewall 防火牆新增規則名稱 ="區塊類型 13 ICMP V4" 通訊協定 = icmpv4:13,任何 dir 作用中 = = 阻斷
如需有關如何設定的 ICMP 設定值的詳細資訊,請執行下列命令:
netsh advfirewall 防火牆新增規則嗎?

範例 5: 設定記錄

摺疊此表格展開此表格
舊的命令新的命令
netsh 防火牆設定 4096 啟用 [啟用記錄 %systemroot%\system32\LogFiles\Firewall\pfirewall.log請執行下列命令:

netsh advfirewall 設定記錄檔名 %systemroot%\system32\LogFiles\Firewall\pfirewall.log currentprofile

netsh advfirewall 設定 currentprofile 記錄 maxfilesize 4096
netsh advfirewall 組 currentprofile 記錄 droppedconnections 啟用

netsh advfirewall 組 currentprofile 記錄 allowedconnections 啟用
如需詳細資訊,請執行下列命令:
netsh advfirewall 設定 currentprofile 嗎?
如果您想要設定的特定設定檔,記錄功能請使用下列選項之一,而非"currentprofile"選項:
  • Domainprofile
  • Privateprofile
  • Publicprofile

啟用 「 Windows 防火牆 」 範例 6:

摺疊此表格展開此表格
舊的命令新的命令
netsh 防火牆設定 opmode 啟用netsh advfirewall 上設定 currentprofile 狀態
netsh 防火牆設定 opmode 模式 = 啟用例外狀況私人網路請執行下列命令:

Netsh advfirewall 上設定 currentprofile 狀態

netsh advfirewall 設定 currentprofile firewallpolicy blockinboundalways,allowoutbound
netsh 防火牆設定 opmode 模式 = 啟用例外狀況 = 停用設定檔: 網域請執行下列命令:

Netsh advfirewall 上設定 domainprofile 狀態

netsh advfirewall 設定 domainprofile firewallpolicy blockinbound,allowoutbound
netsh 防火牆設定 opmode 模式 = 啟用設定檔 = 全部請執行下列命令:

netsh advfirewall 上設定 domainprofile 狀態

netsh advfirewall 上設定 privateprofile 狀態
如需詳細資訊,請執行下列命令:
netsh advfirewall 設定 currentprofile 嗎?
如果您想要設定的防火牆狀態特定的設定檔,使用下列其中一個選項代替"currentprofile"選項:
  • Domainprofile
  • Privateprofile
  • Publicprofile

範例 7: 還原原則預設值

摺疊此表格展開此表格
舊的命令新的命令
netsh 防火牆重設netsh advfirewall 重設
如需詳細資訊,請執行下列命令:
netsh advfirewall 重設?

例如 8: 啟用特定的服務

摺疊此表格展開此表格
舊的命令新的命令
必要的服務 FileAndPrintnetsh advfirewall 防火牆設定規則群組 ="檔案及印表機共用" 新的啟用 = 是
RemoteDesktop 啟用必要的服務netsh advfirewall 防火牆設定規則群組私人 「 遠端桌面 」 的新網路 = 是
netsh 防火牆設定服務 RemoteDesktop 啟用設定檔 = 全部請執行下列命令:

netsh advfirewall 防火牆設定規則群組私人 「 遠端桌面 」 的新網路 = [是] 的設定檔: 網域

netsh advfirewall 防火牆設定規則群組私人 「 遠端桌面 」 的新網路 = [是] 的設定檔 = 私用

這篇文章中的資訊適用於:
  • Windows Server 2008 Enterprise
  • Windows Server 2008 Datacenter
  • Windows Server 2008 Standard
  • Windows Server 2008 for Itanium-Based Systems
  • Windows Web Server 2008
  • Windows Vista 旗艦版
  • Windows Vista 旗艦 64 位元版
  • Windows Vista 商用進階版
  • Windows Vista 商用進階 64 位元版
  • Windows Vista 商用入門版
  • Windows Vista 商用入門 64 位元版
  • Windows Vista 家用進階版
  • Windows Vista 家用進階 64 位元版
  • Windows Vista 家用入門版
  • Windows Vista 家用入門 64 位元版
  • Windows 7 Enterprise
  • Windows 7 Home Basic
  • Windows 7 Professional
  • Windows 7 Starter
  • Windows 7 Ultimate
  • Windows 7 Home Premium
  • Windows Server 2008 R2 Datacenter
  • Windows Server 2008 R2 Enterprise
  • Windows Server 2008 R2 Standard
關鍵字:?
kbpubtypekc kbinfo kbhowto kbmt KB947709 KbMtzh
機器翻譯機器翻譯
重要:本文是以 Microsoft 機器翻譯軟體翻譯而成,而非使用人工翻譯而成。Microsoft 同時提供使用者人工翻譯及機器翻譯兩個版本的文章,讓使用者可以依其使用語言使用知識庫中的所有文章。但是,機器翻譯的文章可能不盡完美。這些文章中也可能出現拼字、語意或文法上的錯誤,就像外國人在使用本國語言時可能發生的錯誤。Microsoft 不為內容的翻譯錯誤或客戶對該內容的使用所產生的任何錯誤或損害負責。Microsoft也同時將不斷地就機器翻譯軟體進行更新。
按一下這裡查看此文章的英文版本:947709? (http://support.microsoft.com/kb/947709/en-us/ )
Microsoft及(或)其供應商不就任何在本伺服器上發表的文字資料及其相關圖表資訊的恰當性作任何承諾。所有文字資料及其相關圖表均以「現狀」供應,不負任何擔保責任。Microsoft及(或)其供應商謹此聲明,不負任何對與此資訊有關之擔保責任,包括關於適售性、適用於某一特定用途、權利或不侵權的明示或默示擔保責任。Microsoft及(或)其供應商無論如何不對因或與使用本伺服器上資訊或與資訊的實行有關而引起的契約、過失或其他侵權行為之訴訟中的特別的、間接的、衍生性的損害或任何因使用而喪失所導致的之損害、資料或利潤負任何責任。