如何更改/查看 Windows 机器上的临时端口范围?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7006939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change/view the ephemeral port range on Windows machines?
提问by Dungeon Hunter
In Linux I can view or change the ephemeral port range using the /proc/sys/net/ipv4/ip_local_port_range
file.
在 Linux 中,我可以使用该/proc/sys/net/ipv4/ip_local_port_range
文件查看或更改临时端口范围。
How can I view or change the ephemeral port range on a Windows machine?
如何查看或更改 Windows 计算机上的临时端口范围?
采纳答案by glglgl
http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html#Windowssays:
http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html#Windows说:
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.
根据 Microsoft 知识库文章929851,从 Windows Vista 和 Windows Server 2008 开始,Windows 现在默认使用大范围 (49152-65535) 。同一篇文章还展示了如何根据需要更改范围,但默认范围现在对于大多数服务器来说已经足够了。
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:
对于较旧的 Windows 操作系统(Windows XP 和更早版本),Windows 使用 1024 到 4999 的传统 BSD 范围作为其临时端口范围。不幸的是,您似乎只能设置临时端口范围的上限。以下信息摘自 Microsoft 知识库文章196271:
- Start Registry Editor (Regedt32.exe).
- Locate the following key in the registry:
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.
- Quit Registry Editor.
- 启动注册表编辑器 (Regedt32.exe)。
- 在注册表中找到以下项:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
在编辑菜单上,单击添加值,然后添加以下注册表值:
Value Name: MaxUserPort Data Type: REG_DWORD Value: 65534 <for example>
有效范围:5000-65534(十进制) 默认值:0x1388(5000 十进制)
说明:此参数控制应用程序从系统请求任何可用用户端口时使用的最大端口号。通常,临时(即短期)端口分配在 1024 和 5000(含)之间。
- 退出注册表编辑器。
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).
注意:还有另一篇相关的知识库文章 ( 812873) 声称允许您设置排除范围,这可能意味着您可以排除端口 1024-9999(例如)以使临时端口范围为 10000-65534。但是,我们还没有能够让它发挥作用(截至 2004 年 10 月)。
回答by Joshua
ReservedPorts is not supported for versions > Windows Server 2003.
版本 > Windows Server 2003 不支持 ReservedPorts。
There is a hotfix to add the missing functionality via netsh.
有一个修补程序可以通过 netsh 添加缺少的功能。