gpt4 book ai didi

command-line - 为什么 Windows 命令外壳告诉我使用不同的命令然后说该命令不存在?

转载 作者:可可西里 更新时间:2023-11-01 02:32:37 24 4
gpt4 key购买 nike

关于我的手持设备 > 服务器应用程序使用此处讨论的 Web API RESTful 方法问题 (Does an ASP.NET Web API app need to be installed into the "real" IIS before a handheld device can access its RESTful methods?),我试图通过使用此处描述的 shell 命令来验证我没有遇到防火墙问题:http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx , 明确地:

netsh firewall add portopening TCP 80 IISExpressWeb enable ALL

我也使用端口 777 完成了它,因为这是我在 applicationhost.config 中设置的端口:

<bindings>
<binding protocol="http" bindingInformation="*:28642:localhost" />
<binding protocol="http" bindingInformation="*:777:192.168.125.50" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>

这样做,我从命令 shell 得到了这个 fingerwag:

重要提示:命令已成功执行。但是,“netsh firewall”已被弃用;请改用“netsh advfirewall 防火墙”。

所以,然后我输入了以下内容(传统/默认端口 80,如 Hanselmann 的帖子所示,然后是我在 trad 失败时添加到 applicationconfig.host 的端口 (777)),一个接一个:

netsh advfirewall firewall add portopening TCP 80 IISExpressWeb enable ALL
netsh advfirewall firewall add portopening TCP 777 IISExpressWeb enable ALL

但是,在输入 command shell 的命令(或建议)后,我从 cmd shell 得到以下反馈(两次):

未找到以下命令:advfirewall firewall add portopening TCP 80 IISExpressWeb enable ALL。

所以它告诉我使用新奇的命令,然后说没有这样的东西!这是什么故事?有没有办法实际使用新命令?是我的语法有问题,还是...???

最佳答案

正在打字 netsh /?在命令提示符处解释了可用的选项,以及要查看有关要键入的选项的信息 netsh <option> /? .这样做与

I:\>netsh advfirewall /?

The following commands are available:

Commands in this context:
? - Displays a list of commands.
consec - Changes to the `netsh advfirewall consec' context.
dump - Displays a configuration script.
export - Exports the current policy to a file.
firewall - Changes to the `netsh advfirewall firewall' context.
help - Displays a list of commands.
import - Imports a policy file into the current policy store.
mainmode - Changes to the `netsh advfirewall mainmode' context.
monitor - Changes to the `netsh advfirewall monitor' context.
reset - Resets the policy to the default out-of-box policy.
set - Sets the per-profile or global settings.
show - Displays profile or global properties.

The following sub-contexts are available:
consec firewall mainmode monitor

To view help for a command, type the command, followed by a space, and then
type ?.

可以申请<command> /?更深,例如 netsh advfirewall firewall /? ,这会导致“netsh advfirewall firewall add/?”,这会导致

I:\>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=a
ny)]
[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)]

Remarks:

- Add a new inbound or outbound rule to the firewall policy.
- Rule name should be unique and cannot be "all".
- If a remote computer or user group is specified, security must be
authenticate, authenc, authdynenc, or authnoencap.
- Setting security to authdynenc allows systems to dynamically
negotiate the use of encryption for traffic that matches
a given Windows Firewall rule. Encryption is negotiated based on
existing connection security rule properties. This option
enables the ability of a machine to accept the first TCP
or UDP packet of an inbound IPsec connection as long as
it is secured, but not encrypted, using IPsec.
Once the first packet is processed, the server will
re-negotiate the connection and upgrade it so that
all subsequent communications are fully encrypted.
- If action=bypass, the remote computer group must be specified when dir=i
n.
- If service=any, the rule applies only to services.
- ICMP type or code can be "any".
- Edge can only be specified for inbound rules.
- AuthEnc and authnoencap cannot be used together.
- Authdynenc is valid only when dir=in.
- When authnoencap is set, the security=authenticate option becomes an
optional parameter.

Examples:

Add an inbound rule with no encapsulation security for messenger.exe:
netsh advfirewall firewall add rule name="allow messenger"
dir=in program="c:\programfiles\messenger\msmsgs.exe"
security=authnoencap action=allow

Add an outbound rule for port 80:
netsh advfirewall firewall add rule name="allow80"
protocol=TCP dir=out localport=80 action=block

Add an inbound rule requiring security and encryption
for TCP port 80 traffic:
netsh advfirewall firewall add rule
name="Require Encryption for Inbound TCP/80"
protocol=TCP dir=in localport=80 security=authdynenc
action=allow

Add an inbound rule for messenger.exe and require security
netsh advfirewall firewall add rule name="allow messenger"
dir=in program="c:\program files\messenger\msmsgs.exe"
security=authenticate action=allow

Add an authenticated firewall bypass rule for group
acmedomain\scanners identified by a SDDL string:
netsh advfirewall firewall add rule name="allow scanners"
dir=in rmtcomputergrp=<SDDL string> action=bypass
security=authenticate

Add an outbound allow rule for local ports 5000-5010 for udp-
Add rule name="Allow port range" dir=out protocol=udp localport=5000-5010
action=allow

关于command-line - 为什么 Windows 命令外壳告诉我使用不同的命令然后说该命令不存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19865541/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com