windows 查看防火墙设置命令使用方法

点击键盘上windows键,输入cmd,选择以管理员身份运行

 输入下面命令查看使用说明

netsh advfirewall firewall add rule ?

发现显示不全,不方便看

可以输入下面命令,生成文件,方便查看

netsh advfirewall firewall add rule ? >d:\1.log

不会再终端窗体上显示了

会在d盘根目录下生成1.log这个文件

双击打开查看

发现显示全了,内容如下


用法: add rule name=<string>
      dir=in|out
      action=allow|block|bypass
      [program=<program path>]
      [service=<service short name>|any]
      [description=<string>]
      [enable=yes|no (default=yes)]
      [profile=public|private|domain|any[,...]]
      [localip=any|<IPv4 address>|<IPv6 address>|<subnet>|<range>|<list>]
      [remoteip=any|localsubnet|dns|dhcp|wins|defaultgateway|
         <IPv4 address>|<IPv6 address>|<subnet>|<range>|<list>]
      [localport=0-65535|<port range>[,...]|RPC|RPC-EPMap|IPHTTPS|any (default=any)]
      [remoteport=0-65535|<port range>[,...]|any (default=any)]
      [protocol=0-255|icmpv4|icmpv6|icmpv4:type,code|icmpv6:type,code|
         tcp|udp|any (default=any)]
      [interfacetype=wireless|lan|ras|any]
      [rmtcomputergrp=<SDDL string>]
      [rmtusrgrp=<SDDL string>]
      [edge=yes|deferapp|deferuser|no (default=no)]
      [security=authenticate|authenc|authdynenc|authnoencap|notrequired
         (default=notrequired)]

备注:

      - 将新的入站或出站规则添加到防火墙策略。
      - 规则名称应该是唯一的,且不能为 "all"。
      - 如果已指定远程计算机或用户组,则 security 必须为
        authenticate、authenc、authdynenc 或 authnoencap。
      - 为 authdynenc 设置安全性可允许系统动态协商为匹配
        给定 Windows Defender 防火墙规则的通信使用加密。
        根据现有连接安全规则属性协商加密。
        选择此选项后,只要入站 IPsec 连接已设置安全保护,
        但未使用 IPsec 进行加密,计算机就能够接收该入站连接的第一个 TCP 或
        UDP 包。
        一旦处理了第一个数据包,服务器将重新协商连接并对其进行升级,以便所
        有后续通信都完全加密。
      - 如果 action=bypass,则 dir=in 时必须指定远程计算机组。
      - 如果 service=any,则规则仅应用到服务。
      - ICMP 类型或代码可以为 "any"。
      - Edge 只能为入站规则指定。
      - AuthEnc 和 authnoencap 不能同时使用。
      - Authdynenc 仅当 dir=in 时有效。
      - 设置 authnoencap 后,security=authenticate 选项就变成可选参数。

示例:

      为不具有封装的 messenger.exe 添加入站规则:
      netsh advfirewall firewall add rule name="allow messenger"
      dir=in program="c:\programfiles\messenger\msmsgs.exe"
      security=authnoencap action=allow

      为端口 80 添加出站规则:
      netsh advfirewall firewall add rule name="allow80"
      protocol=TCP dir=out localport=80 action=block

      为 TCP 端口 80 通信添加需要安全和加密的入站规则:
      netsh advfirewall firewall add rule
      name="Require Encryption for Inbound TCP/80"
      protocol=TCP dir=in localport=80 security=authdynenc
      action=allow

      为 messenger.exe 添加需要安全的入站规则:
      netsh advfirewall firewall add rule name="allow messenger"
      dir=in program="c:\program files\messenger\msmsgs.exe"
      security=authenticate action=allow

      为 SDDL 字符串标识的组 acmedomain\scanners 添加
     经过身份验证的防火墙跳过规则:
     netsh advfirewall firewall add rule name="allow scanners"
      dir=in rmtcomputergrp=<SDDL string> action=bypass
      security=authenticate

      为 udp- 的本地端口 5000-5010 添加出站允许规则
      Add rule name="Allow port range" dir=out protocol=udp localport=5000-5010 action=allow

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三希

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值