AWS VPC Create Subnet in with different zone
Asked Answered
S

5

21

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
    
Simply answered 13/4, 2014 at 15:4 Comment(0)
D
25

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.

Dehnel answered 13/4, 2014 at 15:28 Comment(5)
I just tried to add the range which you mentioned but none of them were working as you mentioned. Is there any work around with that to add subnet with CIDR in Amazon AWS ?Simply
Did you try a VPC of CIDR 192.168.0.0/24 for example ? (in the subnet 192.168.0.0/16)Dehnel
The point 1 described in my question description. this is the error I am getting.Simply
alternativey OP can use online CIDR calculators to know if thier is any overlap.Nilson
very helpful explanation i always revisitMagnitude
P
13

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

Pupiparous answered 29/11, 2017 at 6:35 Comment(1)
This is the right answer, and solves the issue of an existing overlap.Acclimatize
A
10

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

Antimacassar answered 13/4, 2014 at 19:26 Comment(0)
A
3

Still don't understand this fully.

But if you are trying to setup a VPC on AWS, this online tool definitely helps.

http://www.davidc.net/sites/default/subnets/subnets.html

You enter your network address (For e.g., 10.0.0.0) and mask bits (For e.g., 24), it would show a single subnet with all ips, keep dividing as per your requirement, and then use the column "Subnet address" from this table to populate "IPv4 CIDR block" of AWS VPC's subnets.

Advocate answered 29/11, 2020 at 15:1 Comment(0)
M
2

The part behind the slash indicates how many binary numbers you want to fix. So the IP address 1.0.0.0, for example, has 4 values that can vary between 0 and 255 (or 4*8 binary values). If you set the range to 1.0.0.0/0 you will fix 0 values and your range is of size 255*255*255*255 = 4228250625. If you set it to 1.0.0.0/24, you will fix 24 of the 32 binary values. Your range will be 254 IP addresses, from 1.0.0.1 to 1.0.0.255. Or in binary: from 00000001.00000000.00000000.00000001 to 00000001.00000000.00000000.11111111

Since the subnet is in the range of your VPC, make sure to allocate a large pool for your VPC, and then divide that pool in smaller subnets.

Much answered 23/10, 2018 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.