码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2019-08-27 19:01:13      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:默认   启用   pre   stat   拒绝   add   445端口   htm   https   

(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命令行管理防火墙

标签:默认   启用   pre   stat   拒绝   add   445端口   htm   https   

原文地址:https://www.cnblogs.com/rainbow-ink/p/11420147.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!