Skip to content

What is IP address or CIDR range? How do IP addresses work?

After more than 15 years in IT industry and working on various projects as a Team Leader and Solutions Architect, I still find people in my industry who are unable to properly know how do IP addresses work.

I find people who know IPs but if we ask how many IPs are there in /32 or say /24 range then they are often spellbound and give excuses like I am not from Networking or that is not my field of work.

Well, you are not alone if you have been complicating things in your head about IP ranges then obviously things get messy and they don’t stick to your head.

In this post, I will explain the IP addresses or CIDR range in pretty easy layman terms so that it sticks to your brain for your entire life that how do IP addresses work. Let’s get started.

IPV4 – IP addresses Version 4

Most IP addresses we currently use are IPV4 that stands for IP addresses version 4 or to easier to understand since it said 4 versions there are 4 Sections in it. Similarly recently Internet Engineering Task Force (IETF) introduced IPV6 which accommodated a lot more IPs we will not go into IPV6 in this one.

The IPV4 address looks like following:

192.168.30.10 (4 Sections are separated by a .)

Each Section has 8 bytes in it so altogether it has 32 bytes

You can visualise the IP address in Bytes as below each byte represented by 1

11111111.11111111.11111111.11111111

Since the numbers, 1s in the 4 sections of IP addresses are represented as Binary numbers (1, 0) that the computer recognizes.

But for the human-readable form, we have to convert the binary number to a decimal number you can use the Binary to Decimal Conversion tool if you don’t want to go to math about this.

What is Subnet Mask?

Ok so far so good we now applied our numbers int the Binary to decimal conversion tool and it gave us the number 255 for 11111111.

That means the above IP addresses in Binary form can be represented as:

255.255.255.255 (so these are called the subnet masks of IP addresses)

We have to understand is that each section 255 accommodates a total number of 256 spaces or IP addresses. Why 256 that is because the number 0 can also hold 1 space or IP that means 0 to 255 is 256 IP addresses.

So altogether the IPv4 contains 256 X 256 X 256 X 256 IP addresses. And when the Ip address is represented by /32 or /24 it means that it has used up 32 bytes or 24 bytes. So if all 32 bytes are used up that means there is only one space available which is allocated for 0 in the range 0 to 255. If this gets confused you will clearly know by looking at the below table:

Before we go to the table there are few things that we need to remember.

  1. In IP address ranges 1st IP is reserved for Network Subnet itself and the Last or 255th address is reserved for network broadcasting.
  2. Today, classless IP addresses with variable-length subnet masks are used almost exclusively, and classful IP addresses — known as either Class A network, Class B network or Class C network — are used only for certification testing or older routing protocols. A Class D network is used for multicast, and there is an experimental allocation known as Class E.

Table to know exactly how the IP addresses, subnets and prefixes is allocated

Ip AddressesBitsPrefixSubnet MaskNotes
10/32255.255.255.255There is only one IP on the location
0 and thus used up all 32 bits so the
Prefix is /32
21/31255.255.255.254Since 1 bit is used so as in the Subnet Mask
which contains 2 IPs 255-254 = 1 + 0(1) = 2 IPs
2bytes remain
42/30255.255.255.252And since 2 bytes are reduced so is the
Subnetmask reduced by 2.
Number IPs are 255-252 = 3 + 0(1)=4 IPs
or 4 bytes remain
83/29255.255.255.2483 bytes are reduced so
255- 248 = 7 + 0(1) = 8 IPs or bytes remain
164/28255.255.255.2404 bytes are reduced so
255-240= 15 + 0(1) = 16 ips or bytes
325/27255.255.255.2245 bytes are reduced so
255-224 =31 +0(1) ips or bytes
646/26255.255.255.192Similar to above you can just do this process
1287/25255.255.255.128
2568/24255.255.255.0Now one octet (8 bits) is complete here
5129/23255.255.254.0Now we are taking 1 off the second octet
102410/22255.255.252.0
204811/21255.255.248.0
4k + 12/20255.255.240.0
8k +13/19255.255.224.0
16k + 14/18255.255.192.0
32k + 15/17255.255.128.0
64k +16/16255.255.0.0Second octet complete
128k +17/15255.254.0.0
256k +18/14255.252.0.0
512k + 19/13255.248.0.0
1 M + 20/12255.240.0.0
2 M +21/11255.224.0.0
4M +22/10255.192.0.0
8M +23/9255.128.0.0
16M +24/8255.0.0.0Third octet Complete
32M +25/7254.0.0.0
64M +26/6252.0.0.0
128M +27/5248.0.0.0
256M +28/4240.0.0.0
512M +29/3224.0.0.0
1024M +30/2192.0.0.0
2048 M +31/1128.0.0.0
4096 M+32/00.0.0.0Well these are all the IP lists we have in IPV4

Hope this will explain most of the IP basic knowledge issues.

I would like to add a small quiz so that you can familiarise yourself with likely questions that may arise at the workplace that you can easily relate to.

Let’s assume you are looking at IP: 192.168.0.0/16

A. What is the Subnet Mask for this IP address?

Answer: Since there 2 octets used up ie 16 bits are used up so its subnet mask is 255.255.0.0

B. What is the NetworkID for this?

Answer: The Network ID for this is first 2 octets ie. 192.168

C. How many devices can be accommodated in this network?

Answer: Total no of devices are 255 x 255 = 65536 – 2 = 65,534

3 Comments

  1. […] (CIDR) or subnets. To know more about IP address or CIDR ranges you can refer to my article “What is IP address or CIDR range? How do IP addresses work?”. For AWS VPC design the main things that should be taken into consideration […]

Leave a Reply

Your email address will not be published. Required fields are marked *