AWS:在 VPC 之间共享 "NAT Gateway"

AWS: Share "NAT Gateway" among VPCs

我有一个 VPC,我在其中配置了 NAT 网关。另一个 VPC 没有任何 "public subnet" 也没有 IGW。我想在多个 VPC 之间共享一个 NAT 网关。 我尝试配置路由 table 但它不允许从不同的 VPC 指定 NAT 网关。 作为可能的解决方案,我在带有 IGW 的 VPC 中安装了 http/s 代理,并在不同 VPC 中的每个实例上配置了代理设置。它有效,但我想使用 NAT 网关 因为更容易管理。 是否可以在 AWS 进行这种配置? VPC很少,不想每个VPC都加NAT Gateway

兹登科

您不能在多个 VPC 之间共享一个 NAT 网关。

要访问另一个 VPC 中的资源而不通过 Internet 来回访问需要 VPC 对等或其他类型的 VPC 到 VPC VPN,并且这些安排不允许传输流量,这是有充分理由的。因此:

You cannot route traffic to a NAT gateway through a VPC peering connection, a VPN connection, or AWS Direct Connect. A NAT gateway cannot be used by resources on the other side of these connections.

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-nat-gateway.html#nat-gateway-other-services

根据定义,原始 VPC 中的实例是 "on the other side of" 列出的互连安排之一。

AWS Transit Gateway 现在提供了一个选项让您随心所欲,但您需要考虑所涉及的费用——按小时和数据收费。发布了一个参考架构,其中多个 VPC 共享一个 NAT 网关,不允许 VPC 之间的流量:

https://aws.amazon.com/blogs/networking-and-content-delivery/creating-a-single-internet-exit-point-from-multiple-vpcs-using-aws-transit-gateway/

你基本上有3个选择

  • 连接到共享 VPC(通常在共享“网络”帐户中),该 VPC 通过 VPC 对等连接持有 NAT。 VPC 对等连接没有额外费用,但如果您有很多账户,设置起来会很麻烦
  • 相同,但使用 Transit Gateway。 Peering Attachment 的成本几乎与单个 NAT 相同,因此只有在使用多个 NAT 网关以获得高带宽时才会节省成本
  • 设置共享 VPC(例如,在持有 NAT 的基础设施帐户中。然后通过 AWS 资源管理器 (RAM) 将私有子网共享给需要传出访问权限的 VPC。这还有一个额外的好处,您可以在一个地方您分配 VPC IP 范围,并不是每个帐户都需要设置完整的 VPC。AWS VPC sharing best practices 中有更多详细信息。此设置既避免了 Transit Gateway 成本,也避免了设置 VPC 对等的负担。但需要更仔细的规划保持事物隔离(并且可能不是同一 VPC 中的所有事物)