12

My VPC CIDR block is 10.0.0.0/16 As I understand it, this should support 256 (effectively 254) subnets with 65534 hosts per subnet.

When I tried to create one subnet 10.8.0.0/24 and associate it with the VPC, I received this error:

Error creating subnet: 
  InvalidSubnet.Range: The CIDR '10.8.0.0/24' is invalid.

An address like 10.8.0.1 belongs to the subnet 10.8.0.0 which looks to be inside 10.0.0.0/16. Perhaps I am misguided in my understanding. Please explain where I went wrong.

Bon Ami
  • 225
  • 1
  • 2
  • 7
  • 10.8.0.1 is within the 10.0.0.0/8 network, the 10.8.0.0/16 network, and the 10.8.0.0/24 network. Another example, 10.8.5.1 is within the 10.0.0.0/8 network, the 10.8.0.0/16 network, and the 10.8.5.0/24 network. CIDR is a bit funky, I've been working with it for a while and I'm not even 100% sure these examples are correct, so I run everything important past a network engineer. – Tim Dec 10 '18 at 06:22
  • @Tim thanks for offering an explanation. When I get over the Class A, B and C conventions of the past; CIDR makes more sense. – Bon Ami Dec 10 '18 at 18:31

1 Answers1

21

Nope, 10.8.0.0/24 doesn't fall into 10.0.0.0/16. AWS is correct, sorry :)

In your 10.0.0.0/16 you can create subnets between 10.0.0.0/24 to 10.0.255.0/24, e.g. 10.0.8.0/24 would work.


Let's say we've got CIDR address 10.20.30.40 - that can fall for example into these subnets:

  • 10.0.0.0/8 - /8 means only the first byte (10.) in the address is the network address.
  • 10.20.0.0/16 - /16 means the first two bytes (10.20.) are network.
  • 10.20.30.0/24 - /24 means the first three bytes (10.20.30.) are network.
  • 10.20.30.40/32 - /32 covers the whole address (10.20.30.40) and sometimes this notation is used to explicitly say it's a host address. AWS uses that a lot.

Hope that helps :)

MLu
  • 24,849
  • 5
  • 59
  • 86
  • So a /16 means that the first 2 octets is dedicated to the network; and then the user can choose how to partition the 3rd and 4th octets for subnet & hosts. I think I get it now. – Bon Ami Dec 10 '18 at 05:29
  • @BonAmi exactly, added some explanation above. – MLu Dec 10 '18 at 05:31