AWS NACL 和 RDP 问题

AWS NACL and RDP issue

我有一个跨越三个可用区的 VPC,具有 public 个子网。每个AZ有一个子网。这些子网中的每一个都使用应该只允许 HTTP/HTTPS/RDS/SSH 连接的 NACL。我在每个子网中有一个 windows 服务器 运行 来测试。

我正在使用以下入站规则:

和以下允许所有出站流量的出站规则

通过这个 NACL 设置,我可以将 RDP 连接到我的实例中。当我将出站规则更改为如下所示,我将出站连接从 ALL 更改为仅 RDP 时,出现连接超时:

任何人都可以帮助我了解发生了什么以及为什么我的 RDP 会话在这里失败了吗?我想使用此实例将 RDP 连接到同一子网上的其他实例,而不提供所有允许的传出流量。

NACL 强制您为临时端口添加 ALLOW/DENY 规则。当客户端建立套接字连接(在您的情况下为 RDP)时,它会在客户端提供一个 ephermal 端口来接收响应。临时端口是根据操作系统从一个范围内随机选择的。

这里是AWS official documentation about ephermal port.

中提到的范围

Many Linux kernels (including the Amazon Linux kernel) use ports 32768-61000

Requests originating from Elastic Load Balancing use ports 1024-65535

Windows operating systems through Windows Server 2003 use ports 1025-5000

Windows Server 2008 and later versions use ports 49152-65535

A NAT gateway uses ports 1024-65535

AWS Lambda functions use ports 1024-65535

您需要为该范围添加 NACL ALLOW 规则以预测 RDP 会话行为。