大网数据广告活动
服务器运维问答

Public and private subnet in VPC

· 52CE 我爱测

IANA established certain blocks of IP as private IP range(shown below) 10.0.0.0 – 10.255.255.255 (255.0.0.0) 172.16.0.0 – 172.31.255.255 (255.255.0.0) 192.168.0.0 – 192.168.255.255 (255.255.255.0) Public IP addresses will be issu…

问题原文

原帖链接 · overexchange · CC BY-SA 4.0

IANA established certain blocks of IP as private IP range(shown below)

    10.0.0.0 – 10.255.255.255   (255.0.0.0)
    172.16.0.0 – 172.31.255.255  (255.255.0.0)
    192.168.0.0 – 192.168.255.255  (255.255.255.0)

Public IP addresses will be issued by an Internet Service Provider and will have number ranges from 1 to 191 in the first octet, with the exception of the private address ranges that start at 10.0.0 for Class A private networks and 172.16.0 for the Class B private addresses.


To subnet a VPC into one private subnet and one public subnet per zone (as shown below):

Application server sits in private subnet.

NAT gateway and bastion server sits in public subnet

1) Do I need to use private IP range(only) for two private subnets?

2) Do I need to use public IP range(only) for two public subnets?

已采纳解答

原帖链接 · MLu · CC BY-SA 4.0

The whole VPC has one large private address block, e.g. 10.20.0.0/16 and your subnets have slices of this block, e.g.

  • public-az1 and public-az2 will have 10.20.0.0/24 and 10.20.1.0/24
  • private-az1 and private-az2 will have 10.20.2/24 and 10.20.3.0/24

In addition the EC2 instances in the public subnets can have a Public IP or Elastic IP assigned as well. These are allocated one by one by AWS and assigned to the individual instances as requested.


Update: refer to my other answer for details: NAT gateway for ec2 instances

Generally you will have 2 kinds of subnets in a VPC:

  1. Public subnet

    • has IGW and optionally NAT
    • 0.0.0.0/0 there points to the IGW
    • hosts (EC2 instances) get their primary private IPs from the VPC range (10.20.0.0/16), but also ...
    • hosts must have public IP or elastic IP attached as they go directly to the internet
    • hosts can be contacted from the internet on this public/elastic IP (if Security Group permits)
  2. Private subnet

    • has no IGW or NAT
    • the 0.0.0.0/0 points to the NAT in the public subnet above
    • hosts only have private IP from the VPC range and all outbound access is "masked" to the NAT gateway IP
    • hosts can initiate connections to the internet but can't be contacted from outside as they are "hidden" behind the NAT (Network Address Translation gateway).
    • without NAT configured hosts won't have internet access

Hope that clarifies it :)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-12-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。