Most important concept and interesting part in Networking. Everything runs around THIS! There is numerous post written on it, that's why am gonna jump to some most fundamental basics. So that while exploring this topic one can relate what is happening and how... at the back Mind.

An IP address has a total of 32bits.
Something like this:

XXXX.XXXX.XXXX.XXXX

Divided into 4 bytes each, when written in binary-
Something like this:

1111.1111.1111.0101

We as normal human beings cant understand this language, hence we specify usually in understandable numbers.
Something like this:

10.200.16.0 (a typical IP address)

OR

10.200.16.0/24 (an IP with NetMask)

Before we begin, let me give you a little gist.
Let's say I want to create my private network, where I decide what range of IPs I want in my network. So I fixate on some specific IP number range.

Say I want to create a private network named Frozen with IP ranges

10.200.16.0/24

Which means first 24 bits of my IP address i.e. 10.200.16.0 should be constant, which will leave me with available IP address ..i.e.

10.200.16.0 to 10.200.16.255

Basically, /24 is part where I specify what all bits I want it to remain constant. We call it as NetMAsk Masking the networking part of IP. If I say /16: first 16 bits of IP will be constant.

Consider another example, let's take a little tricky example and understand the binary part working, with a much better understanding.

CIDR: 10.200.16.0/20
NetMask is: /20

Here I am saying keep the first 20 bit of my IP as constant. Pretty dope right? calculating in terms of bits itself was confusing. Take it to step by step.

Convert 10.200.16.0 into binary (remember each 4byte is 8bits)

00001010.11001000.00010000.00000000

Our Netmask is 20 convert into binary (first 20 bits are constant)

11111111.11111111.11110000.00000000 (1 means constant/masking)

Here 11110000...highlighted bits are changeable. These 0000 can form all the combinations i.e. 1000 or 0011 or 1110...all possible number will be considered. Which will leave us numbers from 16 to 31 (in 3rd byte of IP)

Therefore we have an available range of address:

10.200.16.0 to 10.200.31.255 (so many IPs)

I can further divide this range to have more control, using the same way. This dividing part is called Subnetting. For above I can divide it further like below:

subnet-1: 10.200.16.0/21
subnet-2: 10.200.24.0/21

So in my network of ranges 10.200.16.0/24 I have two different subnets of the range shown above.

Some quirks:

  • /16 = 65,536 IPs
  • /32 specify one IP
  • /16 > /24 > /32
  • 10.0.0.0 network address
  • 10.0.0.1 reserved by AWS for VPC router.
  • 10.0.0.2 reserved by AWS IP address of the DNS server
  • 10.0.0.3 reserved by AWS for future use
  • 10.0.0.255 network broadcast address. Broadcast is not supported in VPC, therefore this address is reserved.
  • 0.0.0.0/0: any IP

I would suggest going through this link for further understanding:
Understanding IP Addresses, Subnets, and CIDR Notation for Networking
And I strongly recommend to use this link for Calculations
Subnet calculator

Go and explore...Happy learning!