如何更改/查看 Windows 计算机上的临时端口范围?
在 Linux 中,我可以使用 /proc/sys/net/ipv4/ip_local_port_range 文件查看或更改临时端口范围。
如何查看或更改 Windows 计算机上的临时端口范围?
In Linux I can view or change the ephemeral port range using the /proc/sys/net/ipv4/ip_local_port_range
file.
How can I view or change the ephemeral port range on a Windows machine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports .html#Windows 表示:
从 Windows Vista 和 Windows Server 2008 开始,Windows 现在默认使用较大范围 (49152-65535) Microsoft 知识库文章 929851。同一篇文章还介绍了如何根据需要更改范围,但默认范围现在对于大多数服务器来说已经足够了。
对于较旧的 Windows 操作系统(Windows XP 及更早版本),Windows 使用 1024 到 4999 的传统 BSD 范围作为其临时端口范围。不幸的是,您似乎只能设置临时端口范围的上限。以下是摘自 Microsoft 知识库文章 196271 的信息:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
在“编辑”菜单上,单击“添加值”,然后添加以下注册表值:
值名称:MaxUserPort 数据类型:REG_DWORD 值:65534 <例如>
有效范围:5000-65534(十进制)默认值:0x1388(十进制 5000)
描述:此参数控制当应用程序向系统请求任何可用用户端口时使用的最大端口号。通常,临时(即短暂)端口分配的值介于 1024 和 5000(含)之间。
注意:还有另一篇相关知识库文章 (812873)它声称允许您设置排除范围,这可能意味着您可以排除端口 1024-9999(例如)以使临时端口范围为10000-65534。然而,我们还未能使其发挥作用(截至 2004 年 10 月)。
http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html#Windows says:
As of Windows Vista and Windows Server 2008, Windows now uses a large range (49152-65535) by default, according to Microsoft Knowledgebase Article 929851. That same article also shows how you can change the range if desired, but the default range is now sufficient for most servers.
For older Windows operating systems (Windows XP and older), Windows uses the traditional BSD range of 1024 through 4999 for its ephemeral port range. Unfortunately it appears that you can only set the upper bound of the ephemeral port range. Here is information excerpted from Microsoft Knowledgebase Article 196271:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
On the Edit menu, click Add Value, and then add the following registry value:
Value Name: MaxUserPort Data Type: REG_DWORD Value: 65534 <for example>
Valid Range: 5000-65534 (decimal) Default: 0x1388 (5000 decimal)
Description: This parameter controls the maximum port number used when an application requests any available user port from the system. Normally, ephemeral (that is, short-lived) ports are allocated between the values of 1024 and 5000 inclusive.
Note: There is another relevant KB article (812873) which claims to allow you to set an exclusion range, which could mean that you could exclude ports 1024-9999 (for example) to have the ephemeral port range be 10000-65534. However, we have not been able to get this to work (as of October 2004).
这是一个老问题,似乎答案在较新的 Windows 版本中发生了变化(我不确定到底是哪些版本)。
在我的 Windows 10 PC 上,它显示:
要更改它,例如:
This is an old question, and it seems that the answer has changed in newer Windows versions (I'm not sure which ones exactly).
On my Windows 10 PC, it shows:
To change it, eg:
版本 > 不支持保留端口Windows Server 2003。
有一个修补程序可以通过 netsh 添加缺少的功能。
http://support.microsoft.com/kb/2665809
ReservedPorts is not supported for versions > Windows Server 2003.
There is a hotfix to add the missing functionality via netsh.
http://support.microsoft.com/kb/2665809