公网地址与VPC内网地址冲突AWS如何判断target

How can AWS determine target when an Internet address conflicts with an VPC inner address

例如: 您的 VPC CIDR 是 10.0.0.0/16 你有那些路由器表:

10.0.0.0/16 目标:本地
0.0.0.0/0 目标:MyInternetGateway

您有一个 IP 地址为 10.0.3.20

的 EC2 实例

现在您尝试连接一个互联网地址 10.0.3.20,AWS 如何连接到它?

AWS 对路由使用最具体的匹配,因为在使用更广泛的路由规则(如 0.0.0.0.[=15=)让它在野外运行之前,将流量路由到特定路由(如果可用)是合乎逻辑的]

If your route table has multiple routes, we use the most specific route that matches the traffic (longest prefix match) to determine how to route the traffic.

来源:Route Tables - Amazon Virtual Private Cloud

因此在您的场景中,IP 地址 10.0.3.20 将使用最具体的匹配进行路由,即

10.0.0.0/16 target: local

刚刚找到答案:

一些 IPv4 和 IPV6 地址范围保留用于特殊用途:

Reserved_IP_addresses

例如:

10.0.0.0/8 为专用网络保留。

因此没有使用 10.0.0.0/8 的互联网地址。

因此,如果您遵守预订规则,就不会发生地址冲突。