简体   繁体   English

EC2 实例如何访问 Internet IP 以与 EC2 实例所在的 VPC 相同的 CIDR 前缀开始?

[英]How can EC2 instance access internet IP starting with the same CIDR prefix of the VPC the EC2 instance is in?

How can EC2 instance access internet IP starting with the same CIDR prefix of the VPC the EC2 instance is in? EC2 实例如何访问 Internet IP 以与 EC2 实例所在的 VPC 相同的 CIDR 前缀开始?

Assume you have a VPC with CIDR 123.78.0.0/16 and you have the following entry in the routing table to allow VPC EC2 instances to access each other假设您有一个 CIDR 为 123.78.0.0/16 的 VPC,并且您在路由表中有以下条目以允许 VPC EC2 实例相互访问

  • destination:123.78.0.0/16目的地:123.78.0.0/16
  • target:local How can you access an internet server with IP 123.78.xx (for example 123.78.1.1) from an EC2 instance in this VPC? target:local 如何从该 VPC 中的 EC2 实例访问具有 IP 123.78.xx(例如 123.78.1.1)的 Internet 服务器?

You will typically want to use a private IP address range with your VPC to avoid clashing with somebody who owns and operates a public IP address.您通常希望在您的 VPC 中使用私有 IP 地址范围,以避免与拥有和运营公共 IP 地址的人发生冲突。

Private ranges are:私有范围是:

  • 10.0.0.0/8
  • 172.16.0.0/12
  • 192.168.0.0/16

You can also use subsets of these ranges, such as 10.0.0.0/16 .您还可以使用这些范围的子集,例如10.0.0.0/16

The additional benefit of using a private IP range is that Internet traffic cannot route to these IP addresses without going via a NAT Router (such as the one you have at home, which translates a public IP address to a private IP address on your home network). The additional benefit of using a private IP range is that Internet traffic cannot route to these IP addresses without going via a NAT Router (such as the one you have at home, which translates a public IP address to a private IP address on your home network )。

While it is possible to use Public IP addresses (eg 123.78.0.0/16 ) in a VPC, this should be avoided unless you actually own the range and want to allow routing to it.虽然可以在 VPC 中使用公共 IP 地址(例如123.78.0.0/16 ),但应该避免这种情况,除非您实际拥有该范围并希望允许路由到该范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM