欢迎来到悦读文库! | 帮助中心 分享价值,成长自我!
悦读文库

调大动态端口范围解决tcpip告警

问题描述:

1、TCP/IP 无法建立传出连接,因为选定的本地终结点最近用于连接到相同的远程终结点。 当以高速率打开和关闭传出连接时,会导致所有可用的本地端口被使用,并迫使 TCP/IP  重新使用本地端口进行传出连接,此时通常会产生这种错误。为了最大限度地降低数 据受到损坏的风险,在给定的本地终结点和给定的远程终结点之间的连续连接中, TCP/IP 标准需要等待一段最短的时间段。


2、

Event code: 3009 

Event message: 无法向会话状态服务器发出会话状态请求。详细信息: 最后阶段=“正在向状态服务器发送请求”,错误代码=0x80072749,输出数据的大小=123 

Event time: 2022/7/22 16:13:01 

Event time (UTC): 2022/7/22 8:13:01 

Event ID: f9f0da9d3c674410ad7feb532eadd117 

Event sequence: 718619 

Event occurrence: 82071 

Event detail code: 50016 

 

Application information: 

    Application domain: /LM/W3SVC/2/ROOT-1-133028823536155025 

    Trust level: Full 

    Application Virtual Path: / 

    Application Path: D:\wenku\WebUI_Mobile\ 

    Machine name: WIN-B8USIVGK7NB 

 

Process information: 

    Process ID: 9612 

    Process name: w3wp.exe 

    Account name: IIS APPPOOL\m.dswenku.com 

 

Exception information: 

    Exception type: HttpException 

    Exception message: 无法向会话状态服务器发出会话状态请求。请确保 ASP.NET State Service (ASP.NET 状态服务)已启动,并且客户端端口与服务器端口相同。如果服务器位于远程计算机上,请检查 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection 的值,确保服务器接受远程请求。如果服务器位于本地计算机上,并且上面提到的注册表值不存在或者设置为 0,则状态服务器连接字符串必须使用“localhost”或“127.0.0.1”作为服务器名称。


 

 

Request information: 

    Request URL: https://m.dswenku.com:443/download.aspx?id=6834659 

    Request path: /download.aspx 

    User host address: 120.244.123.214 

    User:  

    Is authenticated: False 

    Authentication Type:  

    Thread account name: NT AUTHORITY\IUSR 

 

Thread information: 

    Thread ID: 17 

    Thread account name: NT AUTHORITY\IUSR 

    Is impersonating: False 

    Stack trace: 

 

 解决方案: cmd执行如下命令

netsh int ipv4 set dynamicport tcp start=5001 num=60535

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v "TcpTimedWaitDelay" /t REG_DWORD /d 30 /f


这2句调整的是下面2个注册表

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

"MaxUserPort"=dword:0000f077

"TcpTimedWaitDelay"=dword:0000001e

不需要重启机器

注意:在win10和server2019的系统里,当执行调整tcp动态端口范围的命令时,不会自动生成MaxUserPort,无需人为干预,操作系统已经隐藏MaxUserPort;在<win10和server2019的系统里,执行调整tcp动态端口范围的命令时,会自动生成MaxUserPort。

MaxUserPort并不是最大用户端口号,而是最大用户端口数,其算法是tcp动态端口范围包含的端口数+1024。

比如执行netsh int ipv4 set dynamicport tcp start=10000 num=55535 ,tcp动态端口范围是10000~65534,共55535个端口,MaxUserPort是55535+1024=56559

如果执行netsh int ipv4 set dynamicport tcp start=49152 num=16384复原最初的动态范围会自动生成MaxUserPort=17408,tcp动态端口范围是49152 ~65535,共16384个端口,MaxUserPort是16384+1024=17408

我一般采用dynamicport tcp 5001~65535,即执行netsh int ipv4 set dynamicport tcp start=5001 num=60535

外加

<2012R2和Win8.1的系统,执行:

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v "TcpTimedWaitDelay" /t REG_DWORD /d 30 /f

≥2012R2和Win8.1的系统,执行:

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v "TcpTimedWaitDelay" /t REG_DWORD /d 2 /f

Key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

Value:

TcpTimedWaitDelay

Data Type:

REG_DWORD

Range:

Windows Server 2012 and earlier: 30-300 (decimal)Windows 8 and earlier: 30-300 (decimal)Windows Server 2012 R2 and later: 2-300 (decimal)Windows 8.1 and later: 2-300 (decimal)

Default value:

0x78 (120 decimal)

Recommended value:

30

Value exists by default?

No, needs to be added.


来源:

https://cloud.tencent.com/developer/article/1855881

https://blog.csdn.net/yn_duan/article/details/118054410


分享到微信 分享到微博 分享到QQ空间
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

客服QQ:1356877308

copyright@ 2008-2023 悦读文库网站版权所有

备案ICP备案号:京ICP备18064502号-6