AWS VPC Create Subnet in with different zone

AvtarSingh Suchariya picture AvtarSingh Suchariya · Apr 13, 2014 · Viewed 16.5k times · Source

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
    

Answer

Rico picture Rico · Apr 13, 2014

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.