Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS VPC Create Subnet in with different zone

I already have a VPC (Non Default) configured which is used by Amazon EC2.

I need to create another subnet (Non Default) in the same VPC with a different Availability Zone.

So when I am trying to Add details, I am stuck at the CIDR Block. I am getting 2 errors when trying to set different IPs for CIDR.

  1. CIDR block 192.168.250.225/16 overlaps with pre-existing CIDR block 192.168.0.0/16 from subnet-6afacb2c (192.168.0.0/16) | AvtarSingh Public Subnet.

  2. 192.167.250.225/16 is not within the range of 192.168.0.0/16

I tried many combinations that I was able to think, but none of them are working for me.

I am sorry but I don't have much knowledge of CIDR. So can you give me the correct CIDR for current configuration ? Right now, I just want to set the development environment so want to check.

Following is current VPC & Subnet details:

  1. VPC

    VPC ID: vpc-8fe804ea | AvtarSingh VPC
    Network ACL: acl-406a8725
    State: available
    Tenancy: Default
    VPC CIDR: 192.168.0.0/16
    DNS Resolution: yes
    DHCP Options Set: dopt-0d6a7c6f
    DNS Hostnames: yes
    Route Table: rtb-18739f7d
    
  2. Subnet

    Subnet ID: subnet-6afacb2c | AvtarSingh Public Subnet
    Availability Zone: us-west-2c
    CIDR: 192.168.0.0/16
    Route Table: rtb-1b739f7e
    State: available
    Network ACL: acl-406a8725
    VPC: vpc-8fe804ea (192.168.0.0/16) | AvtarSingh VPC
    Default Subnet: no
    Available IPs: 65530
    
like image 632
AvtarSingh Suchariya Avatar asked Apr 13 '14 15:04

AvtarSingh Suchariya


People also ask

Can we create subnet in different availability zone?

You can specify the Availability Zone in which you want the subnet to reside. You can have multiple subnets in the same Availability Zone. You can optionally specify an IPv6 CIDR block for a subnet if there is an IPv6 CIDR block associated with the VPC. If you create an IPv6-only subnet, be aware of the following.

Why do you need to create subnets in different availability zones?

Each subnet must reside entirely within one Availability Zone and cannot span zones. By launching instances in separate Availability Zones, you can protect your applications from the failure of a single zone.

Can we connect VPC in different regions?

You can peer any two VPCs in different Regions, as long as they have distinct, non-overlapping CIDR blocks. This ensures that all of the private IP addresses are unique, and it allows all of the resources in the VPCs to address each other without the need for any form of network address translation (NAT).


3 Answers

So basically you created your subnet in the 192.168.0.0/16 range which also means a subnet mask of 255.255.0.0 Your address range for this block is 192.168.0.0-192.168.255.255 so you can use any range in that block for your CIDR block.

So a CIDR block of 192.168.250.225/16 will also have the same address range of 192.168.0.0/16 because you are using the same subnet mask 255.255.0.0 (that's what the /16 means at the end of the address).

You can read more about it here: http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

What you want is a CIDR block that is within the 192.168.0.0/16 range, so blocks like these will work for example: 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24, 192.168.128.0/24, (these blocks have 256 possible addresses - broadcast and gateway) 192.168.20.0/23 (This block has 512 possible addresses - broadcast and gateway). So in essence, anything that is within the 192.168.0.0/16 and doesn't overlap with an existing CIDR block.

Hope this helps.

like image 188
Rico Avatar answered Oct 21 '22 09:10

Rico


You need to edit the CIDR for your VPC and add another CIDR block, say - 192.169.0.0/16. Then navigate to subnets and create the subnet with that range as below :

enter image description here

like image 12
sudheep k Avatar answered Oct 21 '22 08:10

sudheep k


Your cidr and your VPC are the exact same size.

You need to delete your first subnet so that you can re-cut into multiple subnets.

Rico was leading you down the right path with his /24 examples.

Another good tip is to use a CIDR calculator when making your subnets to see how many address you are going to take up when declaring the new subnet.

One of the simpler ones to use in in my opionin is here

like image 8
pquery Avatar answered Oct 21 '22 08:10

pquery