Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple VPC and Subnet with same CIDR blocks

I realized that I can create multiple AWS VPCs and Subnets with Same CIDR blocks, I am not sure what is the philosophy behind that and how it is possible.

like image 590
Vaibhav Jain Avatar asked Jul 11 '16 07:07

Vaibhav Jain


People also ask

Can we have 2 VPC with same CIDR?

Two VPCs with multiple CIDRs peered togetherYou can add IPv4 CIDR blocks to your VPC. In this example, VPC A and VPC B have multiple IPv4 CIDR blocks. The route tables for each VPC point to the VPC peering connection to access all the IPv4 CIDR blocks of the peer VPC.

Can a subnet span multiple VPC?

The subnet can span the entire IP range of the VPC, as below: Alternatively, we could split the range of IP addresses in the VPC into multiple subnets, as below: In the above scenario we're not using the full IP range of the VPC, allowing ourselves the space to create more subnets in future (e.g. for 10.0. 2.0/24 ).

What are overlapping CIDR blocks?

VPC A and VPC M have overlapping CIDR blocks. This means that peering traffic between VPC A and VPC C is limited to a specific subnet (subnet A) in VPC C. This is to ensure that if VPC C receives a request from VPC A or VPC M, it sends the response traffic to the correct VPC.

How many IPv4 CIDR blocks can you create per VPC?

You assign a single Classless Internet Domain Routing (CIDR) IP address range as the primary CIDR block when you create a VPC and can add up to four (4) secondary CIDR blocks after creation of the VPC.


1 Answers

AWS VPCs can exist in private (RFC 1918) IPv4 space. (You can also create them with public IP CIDR blocks, but this is less common as you must own your own IPv4 block.) Private IPv4 addresses are not directly routable from the Internet, and traffic to/from the Internet must generally go through Network Address Translation (NAT). Therefore, you can have multiple occurences of the CIDR block in these private spaces because they cannot route to each other directly. You cannot have multiple subnets with the same (or overlapping) CIDR blocks in the same VPC, though, because AWS treats it as one continuous network.

Reserved RFC 1918 CIDR blocks (AWS will let you use any of these for your VPC):

  • 10.0.0.0/8 (The most commonly used, because it's the largest)
  • 192.168.0.0/16 (Also commonly used, generally on home routers or small office networks)
  • 172.16.0.0/12 (Less commonly used, because most people cannot remember how many addresses are in a /12 without a calculator)

You probably do not want to create VPCs with overlapping CIDR blocks if you're creating multiple VPCs, though, because then you cannot link them together later via VPC Peering, because the addresses would no longer be unique in the joined network space. Plan ahead for your current and possible future VPC usage, because you cannot change a VPC's CIDR block after it has been created. You'd have to move everything out and start fresh. The same goes for subnets in a VPC.

like image 75
Karen B Avatar answered Sep 30 '22 06:09

Karen B