Professional Documents
Culture Documents
啟用防火牆:
netsh advfirewall set currentprofile state on
關閉防火牆:
netsh advfirewall set currentprofile state off
netsh advfirewall firewall add rule name="禁止 UDP 5678 連入" protocol=UDP dir=out localport=5678 action=block
如果要允許的連接埠是連續的呢?
例如下面允許 TCP 20、21 連入
netsh advfirewall firewall add rule name="允許 TCP 20~21 連入" protocol=TCP dir=in localport=20-21 action=allow
如果是應用程式的話呢?
netsh advfirewall firewall add rule name="允許 hello.exe 連入" dir=in program="c:\alexc\hello.exe" action=allow
那要怎麼知道防火牆所有的設定呢?
netsh advfirewall firewall show rule name="all"
Example:
netsh advfirewall firewall add rule name = "TCP-SQL Bypass Ports" dir = In protocol = TCP action = allow localport =
netsh advfirewall firewall add rule name = "TCP-SQL Bypass Ports" dir = In protocol = UDP action = allow localport =
netsh advfirewall firewall add rule name = "TCP-SQL Bypass Ports" dir = Out protocol = TCP action = allow localport =
netsh advfirewall firewall add rule name = "TCP-SQL Bypass Ports" dir = Out protocol = UDP action = allow localport =
netsh advfirewall firewall set rule group="Windows Management Instrumentation (WMI)" new enable=Yes