我的防火墙中有一个现有的出站规则,其中包含一组指定的 IP 地址。为了增强安全性,我想使用 shell 脚本将其他 IP 地址附加到此规则。我正在尝试执行以下命令:
netsh advfirewall firewall add rule name="Outbound Rule Name" remoteip=IP_ADDRESS1,IP_ADDRESS2,...
但是,我遇到以下错误消息:
One or more essential parameters were not entered. Verify the required parameters, and reenter them.
我最初怀疑规则本身可能存在问题,但是当我运行命令时:
netsh advfirewall firewall show rule name="Outbound Rule Name"
它确认规则已激活并正常运行。我很困惑添加规则命令可能出了什么问题以及缺少哪些必要参数。
答案1
未输入一个或多个重要参数
您遗漏了两个重要参数:dir
和action
。这些参数定义了规则的方向,可以是入站或者出站,以及行动它应该表现,是否允许或者否认。
具体来说,包括命令中的参数及其值dir=out
。action=allow
电源外壳
netsh advfirewall firewall add rule name="Outbound Rule Name" dir=out remoteip=IP_ADDRESS1,IP_ADDRESS2,... action=allow
到那个时刻使用 NETSH 修改现有的防火墙规则,利用set rule
命令并确保new
包含关键字,但在更新现有规则时不应将其作为最后的参数放置。
电源外壳
netsh advfirewall firewall set rule name="Outbound Rule Name" new dir=out remoteip=IP_ADDRESS1,IP_ADDRESS2,... action=allow
支持资源
netsh advfirewall firewall add rule /?
Usage: 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)]
netsh advfirewall firewall set rule /?
Usage: set rule group=<string> | name=<string> [dir=in|out] [profile=public|private|domain|any[,...]] [program=<program path>] [service=service short name|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] [remoteport=0-65535|<port range>[,...]|any] [protocol=0-255|icmpv4|icmpv6|icmpv4:type,code|icmpv6:type,code| tcp|udp|any] new [name=<string>] [dir=in|out] [program=<program path> [service=<service short name>|any] [action=allow|block|bypass] [description=<string>] [enable=yes|no] [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|RPC|RPC-EPMap|any[,...]] [remoteport=0-65535|any[,...]] [protocol=0-255|icmpv4|icmpv6|icmpv4:type,code|icmpv6:type,code| tcp|udp|any] [interfacetype=wireless|lan|ras|any] [rmtcomputergrp=<SDDL string>] [rmtusrgrp=<SDDL string>] [edge=yes|deferapp|deferuser|no (default=no)] [security=authenticate|authenc|authdynenc|notrequired] For 'set' commands, the 'new' keyword must be present and must not be the last argument provided.