[
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.exe | netsh advfirewall 防火牆刪除規則名稱 =規則名稱 程式 ="C:\MyApp\MyApp.exe" |
| 刪除 portopening 通訊協定 = UDP 連接埠 = 500 | netsh advfirewall 防火牆刪除規則名稱 =規則名稱 通訊協定 = udp localport = 500 |
如需有關如何刪除 [防火牆規則的詳細資訊,請執行下列命令:
netsh advfirewall 防火牆刪除規則嗎?
範例 4: 設定的 ICMP 設定值
摺疊此表格展開此表格
| 舊的命令 | 新的命令 |
|---|
| netsh 防火牆設定 icmpsetting 8 | netsh 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: 啟用特定的服務
摺疊此表格展開此表格
| 舊的命令 | 新的命令 |
|---|
| 必要的服務 FileAndPrint | netsh advfirewall 防火牆設定規則群組 ="檔案及印表機共用" 新的啟用 = 是 |
| RemoteDesktop 啟用必要的服務 | netsh advfirewall 防火牆設定規則群組私人 「 遠端桌面 」 的新網路 = 是 |
| netsh 防火牆設定服務 RemoteDesktop 啟用設定檔 = 全部 | 請執行下列命令:
netsh advfirewall 防火牆設定規則群組私人 「 遠端桌面 」 的新網路 = [是] 的設定檔: 網域
netsh advfirewall 防火牆設定規則群組私人 「 遠端桌面 」 的新網路 = [是] 的設定檔 = 私用 |