Number of available IP addresses per private IP address range - amazon-web-services

I have a problem with determining the correct number of available IP addresses per private IP address range for an AWS VPC for example.
Given that AWS allows assigning a range starting from a /16 block, I have the following available ranges. Given the fact they take 4 addresses away from me, this leaves me with the following ranges:
10.0.0.4 - 10.0.255.254
172.16.0.4 - 172.16.255.254
192.168.0.4 - 192.168.255.254
According to all calculators available on the internet, I get the same amount of IP addresses (65331). Nevertheless I've seen numerous recommendations to choose 10.0.0.0 as the address range, as it provides the highest number of IP addresses. Can somebody clarify this?
Thank you very much

not sure if I understand your question too well, but I will try to shed some light on what you are asking. AWS uses those 4 IPS for their internal routing and configuration of their network.
Example VPC Address Range: 10.0.0.0/16
If you have this CIDR example, AWS takes the first 4 for their own resources of each SUBNET and you have access to the rest of these IPS in the given SUBNETS.
Now we can break that VPC down into smaller subnets so it can be used for different reasons such as the standard ( Pub / Private ).
Example Subnet : 10.0.0.0/27 = 32 IPS
32 - 4 = 28
AWS Also does not support .255(network broadcast address) of a subnet, so they take the last IP as well which gives you a total for 28 - 1 = 27 IPS for use.
Sources: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html

Related

EC2 Classic Link - Determine Classic IP Range

So, I am working to migrate from EC2 Classic to VPC (yeah, I know, long time in coming and this was an inherited platform).
I have created a VPC and when I go to turn on Classic Link, I get the following error:
The CIDR range of vpc-[id_here] overlaps with the Classic IP space
I looked and was not able to find a way to determine which IP Range(s) Classic uses. Is there a way to find out so I can make my VPC's not stomp all over it?
Thanks!
10.0.0.0/8 as documented here.
As in the comment above:
"VPCs that are in the 10.0.0.0/16 and 10.1.0.0/16 IP address ranges can be enabled for ClassicLink

Error when creating private subnets within AWS VPC

I am currently trying to create a VPC with multiple subnets in AWS. Unfortunately, whenever I go to design the subnets within the VPC I am getting errors. This is my VPC design:
VPC: 10.82.0.0/16
Private Subnets:
10.82.96.0/21
10.82.119.0/21
10.82.194.0/21
10.82.212.0/21
The Error I get is the following for each subnet CIDR except 10.82.96.0/21:
Must be a valid CIDR block.
What am I doing wrong? I just want to create multiple private subnets in this VPC.
A /21 is quite an unusual netmask to be using. It contains 2048 IP addresses.
The netmask for /21 would be:
11111111.11111111.11111000.00000000
Only the zeroes are allowed to change. In binary, 100000000000 is equivalent to 2048 in decimal and 1000 in binary is 8 in decimal.
This means that the second last number would be a multiple of 8 (eg 0, 8, 16, 32).
However, you have not chosen IP addresses that start in a /21 range.
Your chosen subnets would have the following IP address ranges:
CIDR First address Last address
10.82.96.0/21 10.82.96.0 10.82.103.255 Good!
10.82.119.0/21 10.82.112.0 10.82.119.255 Invalid
10.82.194.0/21 10.82.192.0 10.82.199.255 Invalid
10.82.212.0/21 10.82.208.0 10.82.215.255 Invalid
Note that the first line is good because 96 is divisible by 8. Therefore, it is valid in a /21 CIDR.
However, the subsequent lines do not start on a /21 boundary. They are invalid CIDR values.
I highly recommend using a CIDR calculator when determining difficult IP ranges.

Why is 10.0.0.1/28 not a valid subnet within a VPC of 10.0.0.0/24?

How to create Multiple Subnets within Range 10.0.0.0/24.
Tried creating 10.0.0.1/28 . It tells it should be within the CIDR Range.
I am sure am making something wrong . Please advise.
If you have a VPC has : 10.0.0.0/24. then you want to create some subnets are being this VPC.
If you want to create subnet with /28 so:
10.0.0.0/28
10.0.0.16/28
10.0.0.32/28
10.0.0.48/28
10.0.0.64/28
............
10.0.0.240/28
If you want to create subnet with /26:
10.0.0.0/26
10.0.0.64/26
10.0.0.128/26
10.0.0.192/26
The message is misleading. It is not like 10.0.0.1/28 is not within the CIDR range of 10.0.0.0/24, it simply is an incorrect network ID (the message could be slightly more helpful I guess).
You can only specify network ID, not a network address. In your case 10.0.0.1/28 is the first network address from range 10.0.0.0 - 10.0.0.15 where 10.0.0.0/28 is the network ID that you need to use instead. The next network ID for /28 prefix length is 10.0.0.16 as it was mentioned in the other answer.
This is given by subnetting rules. Long story short, if you need to know network IDs then just subtract the prefix, in this case 28 from 32 (32 bits of IPv4 address) which gives you 4 usable bits for hosts which translates to 2^4 = 16 block size. Therefore you can start with 10.0.0.0 and continue by adding 16 to the last number 0, 16, 32, 48, ... and the same goes for the other prefixes as well (or at least if you consider any prefix longer or equal to 24, it kind of works for shorter prefixes as well but you need to be careful which octet of IP address you are modifying).
It is also worth mentioning that the 10.0.0.1/28 is not even a usable IP address on AWS because AWS reserves first 4 and the last one IP address of each subnet (first 4, including network ID, are used for stuff such as DHCP server in your subnet which you don't directly see and the last one is broadcast address which, in general, cannot be assigned to any host, moreover AWS doesn't even support broadcasts).
So technically, when you use 10.0.0.0/28 subnet, you will end up with 11 available IP addresses ranging from 10.0.0.4 to 10.0.0.14.

CIDR range for --master-ipv4-cidr in GKE private cluster

Note:
There is an existing stackoverflow post which discuss about --master-ipv4-cidr, but it doesn't discuss about the topic which I am asking in the question.
Please don't mark this as duplicate.
Problem description
I am creating private clusters in GKE and got confused with the --master-ipv4-cidr range. This link, mentions that --master-ipv4-cidr needed CIDR in RFC 1918 range.
"--master-ipv4-cidr 172.16.0.0/28 specifies an RFC 1918 range for the master. This setting is permanent for this cluster."
Since valid RFC 1918 ranges are
10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
So I tried to create private cluster with following values:
--master-ipv4-cidr "172.17.0.0/28"
--cluster-ipv4-cidr "172.16.128.0/17"
--services-ipv4-cidr "192.168.1.0/24"
Since 172.17.0.0/28 is also from RFC 1918 range I thought that cluster will come up. But it resulted in error as mentioned below
172.17.0.0/16 is a reserved GKE IP range and cannot be used for the 'master-ipv4-cidr'.
Then I changed --master-ipv4-cidr to example given in link and cluster created successfully. Below are the successful case values.
--master-ipv4-cidr "172.16.0.16/28"
--cluster-ipv4-cidr "172.16.128.0/17"
--services-ipv4-cidr "192.168.1.0/24"
Now my question are
Does --master-ipv4-cidr expects CIDR in 172.16.0.0/28 only and it cannot accept any other range from 10/8 or 192.168/16 or any other range for example 172.17.0.0/28 which I provided earlier?
With an existing cluster --master-ipv4-cidr of 172.16.0.0/28, if I create another cluster in same VPC what should be the --master-ipv4-cidr value?
Because creating another cluster with same --master-ipv4-cidr 172.16.0.0/28 fails with below error which is quite expected.
Google Compute Engine: An IP range in the peer network (172.16.0.16/28) overlaps with an IP range (172.16.0.16/28) in an active peer (gke-c2a126697c6fee94c2b8-1e18-f2ff-peer) of the local network.
and thats expected because 172.16.0.16/28 already exist in an existing cluster in same vpc to which its getting peered.
I am thinking to manage my cluster pods from 172.16.0.0 range and services from 192.168.0.0 range of RFC 1918 and not use 10/8 network to avoid conflict with existing office network.
Since 172.16/12 is a superset of 172.16.0.0/28. How do you make sure that they are separated from each other?
Apologies for asking many question here, but I am just trying to keep the entire context at same place.
I will answer your questions as follows:
172.17.0.0 cannot be used because this is for Docker.
You can use any of the following CIDRs 10.0.0.0 – 10.255.255.255, 172.16.0.0 – 172.31.255.255, 192.168.0.0 – 192.168.255.255 except 172.16 and 172.17. Also this must be /28
Supersets or Subnets are not possible therefore you will have to choose a different CIDR range
You can read about the Restrictions and Limitations in the following Google Public doc

How to validate an invalid CIDR block?

I have the following CIDR reserved for my VPC -> 10.0.0.0/22
What this tells me is that I have 10 bits leftover for my host ips or 1,024 addresses. I was attempting to compute the range of valid addresses, as Amazon asks for a valid IPv4 CIDR block when creating a new private subnet.
I figured 6/8 bits are taken from the 3rd octet and the last octet is all 0's, which leads me with an IP range of 10.0.0.0 -> 10.0.3.255.
As I come to the screen to actually pick my IPv4 CIDR block, I'm getting an "Invalid error", which is just validating that I don't understand how the math is actually working work. I typed in 10.0.2.1/28 which yields a Must be valid Ipv4 CIDR error.
My thought process:
This looked like it was in the range I had calculated and that I wanted my private subnet to reserve 16 IP addresses.
What am I doing wrong?
You are starting with a VPC 10.0.0.0/22. You are correct in that the valid addressing range is 10.0.0.0 -> 10.0.3.255.
Now you want to create a subnet from this VPC using /28 CIDR blocks. /28 means the last four bits are 0 to give you the range 0 -> 15. CIDR blocks must always begin on their own boundary. Examples for /28:
10.0.0.0 -> 10.0.0.15
10.0.0.16 -> 10.0.0.31
You tried to create a subnet with the CIDR block 10.0.2.1/28. This is invalid as it does not begin at offset 0 within the valid CIDR range for /28. You can create a valid subnet as 10.0.2.0/28 or 10.0.2.16/28, etc. Notice how the start of each subnet has the last four bits as 0.
A quick way to look at this is for any subnet, the host portion starts at 0 and ends in all ones.
I just want you to tell you the rules to choose CIDR block as follows:
All the IP address should be in contigious.
The number of IP's you can get is in the power of 2n
First IP address in the block should be evenly divisible by the size of block i.e. (2n).
Third point is important as well as related to second point.
10.0.2.1/28 - It is not the proper CIDR block ID.
As 3rd point here not followed.