windows 通过cmd命令行管理防火墙

(1)恢复初始防火墙设置
netsh advfirewall reset
(2)关闭防火墙
netsh advfirewall set allprofiles state off
(3)启用桌面防火墙
netsh advfirewall set allprofiles state on
(4)设置默认输入和输出策略
netsh advfirewall set allprofiles firewallpolicy allowinbound,allowoutbound
以上是设置为允许,如果设置为拒绝使用blockinbound,blockoutbound
(5)关闭tcp协议的139端口
netsh advfirewall firewall add rule name=”deny tcp 139″ dir=in protocol=tcp localport=139 action=block
(6)关闭udp协议的139端口
netsh advfirewall firewall add rule name=”deny udp 139″ dir=in protocol=udp localport=139 action=block
(7)关闭tcp协议的445端口
netsh advfirewall firewall add rule name=”deny tcp 445″ dir=in protocol=tcp localport=445 action=block
(8)关闭udp协议的445端口
netsh advfirewall firewall add rule name=”deny udp 445″ dir=in protocol=udp localport=445 action=block
(9)使用相同的方法,依次关闭TCP协议的21、22、23、137、138、3389、5800、5900端口。
netsh advfirewall firewall add rule name= “deny tcp 21″ dir=in protocol=tcp localport=21 action=block
netsh advfirewall firewall add rule name= “deny tcp 22″ dir=in protocol=tcp localport=22 action=block
netsh advfirewall firewall add rule name= “deny tcp 23″ dir=in protocol=tcp localport=23 action=block
netsh advfirewall firewall add rule name= “deny tcp 3389″ dir=in protocol=tcp localport=3389 action=block 学习电脑
netsh advfirewall firewall add rule name= “deny tcp 5800″ dir=in protocol=tcp localport=5800 action=block
netsh advfirewall firewall add rule name= “deny tcp 5900″ dir=in protocol=tcp localport=5900 action=block
netsh advfirewall firewall add rule name= “deny tcp 137″ dir=in protocol=tcp localport=137 action=block
netsh advfirewall firewall add rule name= “deny tcp 138″ dir=in protocol=tcp localport=138 action=block

以上内容搬运自百度知道https://zhidao.baidu.com/question/2075121309871751268.html,稍作整理

windows 通过cmd命令行管理防火墙

上一篇:C# Newtonsoft.Json解析json字符串处理 - JToken 用法


下一篇:内核基础-API命名-字符