Windows下cmd命令行管理防火墙

xingyun86 2021-10-13 1423

Windows下cmd命令行管理防火墙

防火墙规则允许name相同且行为不一样

(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协议的22端口

    netsh advfirewall firewall add rule name="allow tcp 22″ dir=in protocol=tcp localport=22 action=allow

(6)允许udp协议的22端口

    netsh advfirewall firewall add rule name="allow udp 22″ dir=in protocol=udp localport=22 action=allow

(7)阻断tcp协议的22端口

    netsh advfirewall firewall add rule name="block tcp 22″ dir=in protocol=tcp localport=22 action=block

(8)阻断udp协议的22端口

    netsh advfirewall firewall add rule name="block udp 22″ dir=in protocol=udp localport=22 action=block

(9)删除tcp协议的22端口

    netsh advfirewall firewall delete rule name="allow tcp 22″ dir=in protocol=tcp localport=22

    netsh advfirewall firewall delete rule name="block tcp 22″ dir=in protocol=tcp localport=22

    删除名为"allow tcp 22"的规则:

    netsh advfirewall firewall delete rule name="allow tcp 22"

(10)阻断udp协议的22端口

    netsh advfirewall firewall delete rule name="allow udp 22″ dir=in protocol=udp localport=22

    netsh advfirewall firewall delete rule name="block udp 22″ dir=in protocol=udp localport=22

    删除名为"allow udp 22"的规则:

    netsh advfirewall firewall delete rule name="allow udp 22"

(11)删除本地端口 22 的所有TCP入则:

      netsh advfirewall firewall delete rule name=all protocol=tcp localport=22      

(12)删除本地端口 22 的所有UDP入则:      

      netsh advfirewall firewall delete rule name=all protocol=udp localport=22


×
打赏作者
最新回复 (0)
查看全部
全部楼主
返回