Classless Inter-Domain Routing – method of allocating IP addresses for networks & sub-networks. It improves the distribution of IP addresses.
In this blog we will explore the IPv4 IP Address, Classes of IPv4, Method for allocation IP addresses using CIDR – Classless Inter-Domain Routing.
- IPv4 – 4th version of the Internet Protocol.
- Addresses are 32 bits Integer. Binary at back-end
- Divided in 4 Octets
- It has Network Component & Host Component depending upon Subnet Mask. Will see later.
For example 192.168.0.1 – Valid IPv4 Address. Lets see its binary representation. Below table is used to binary conversion.
27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
192 – Let see which bits are turned on. (128 + 62 = 192)
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
168 – (128 + 32 + 8 = 168)
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
0: All are turned off
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
192.168.0.1 – Binary Representation:
198 | 168 | 0 | 1 |
11000000 | 10101000 | 0000000 | 0000001 |
Classes of IP:
Class | Range | CIDR Notation | Default Subnet |
---|---|---|---|
A | 0.0.0.0 – 127.255.255.255 | /8 | 255.0.0.0 |
B | 128.0.0.0 – 191.255.255.255 | /16 | 255.255.0.0 |
C | 192.0.0.0 – 223.255.255.255 | /24 | 255.255.255.0 |
D | 224.0.0.0 – 239.255.255.255 | ||
E | 240.0.0.0 – 255.255.255.255 |
CIDR Notation – Subnet masks tells us the Network & Host Details:
- /8 – First 8 bits reserved for network & rest are for host
- /16 – First 16 bits reserved for network & rest are forhost
- /24 – First 24 bits reserved for network & rest are forhost
127.0.0.0 – Reserved for loopback network
Reserved Private IPv4 (Which can be used within the local networks)
- 10.0.0.0 – 10.255.255.255
- 172.16.0.0 – 172.31.255.255
- 192.168.0.0 – 192.168.255.255
Network Part & Host Part:
IPv4 has two main component : Network Part & Host Part. To identify the these parts we need Subnet Mask. Subnet Mask is also 32-bit number where network bits are represent as 1 & host bits as 0.
Example 1: Network 192.0.0.0 IP its default Subnet mask = 255.255.255.0 (CIDR /24)
CIDR Notation (/24) – Means 24 bits reserved for network. Rest of 8 for Host.
255.255.255.0 : Binary Representation
11111111 | 11111111 | 11111111 | 00000000 |
Network Bits | Network Bits | Network Bits | Host Bits |
192 Fixed | 0 Fixed | 0 Fixed | 0 – 255 |
- Total no of IP in network = 2No of Host Bits = 28 = 256
- Total no of usable IP in network = 2No of Host Bits – 2= 256
- As 2 IP address reserved for Network IP & Broadcast IP
- First IP – 192.0.0.0 (Network IP)
- Last IP – 192.0.0.255 (Broadcast IP)
- First Usable IP – 192.0.0.1
- Last Usable IP – 192.0.0.254
Example 2: 128.0.0.0 its Subnet mask = 255.255.0.0 (CIDR /16)
11111111 | 11111111 | 00000000 | 00000000 |
Network Bits | Network Bits | Host Bits | Host Bits |
192 Fixed | 0 Fixed | 0 – 255 | 0 – 255 |
- Total no of IP in network = 2No of Host Bits = 216 = 65,536
- Total no of usable IP in network = 2No of Host Bits – 2= 65,534
- As 2 IP address reserved for Network IP & Broadcast IP
- First IP – 192.0.0.0 (Network IP)
- Last IP – 192.0.255.255 (Broadcast IP)
- First Usable IP – 192.0.0.1
- Last Usable IP – 192.0.255.254
Subnetting
So if you are using the default subnets – you are getting list of IPs in that network. Suppose you want to manage the network such like within network you want some sub networks, so you have to borrow the bits from host parts i.e. change the CIDR.

Let see some examples in details.
Example 1: IP :10.0.0.0/20
Subnet Mask: 255.255.240.0 ( CIDR Notation /20)
CIDR Notation (/20) – Means 20 bits turned true for network.
11111111 | 11111111 | 11110000 | 00000000 |
Network Bits | Network Bits | Network/Host Bits | Host Bits |
So we have borrowed here 4 bits (red) from the 3 octet & make it CIDR 20 instead of 16 (255.255.0.0) . Red underlined one is magic number 4th one i.e. 16
10.0.0.0 | 00001010 | 00000000 | 00000000 | 00000000 |
255.255.240.0 | 11111111 | 11111111 | 11110000 | 00000000 |
Logical AND | 00001010 | 00000000 | 00000000 | 00000000 |
10 | 0 | 0 | 0 |
Network Address: 10.0.0.0 , Broadcast Address: 10.0.15.255
- Total no of subnets = 2No of Subnets Bits = 24 = 16 Sub Networks
- Total no of IP in each sub network = 2No of Host Bits = 212 = 4,096
- Total no of usable IP in each sub network = 2No of Host Bits – 2= 4,094
- First IP address reserved for Network IP & Last for Broadcast IP for each subnet
Network Address | Range |
---|---|
10.0.0.0 | 10.0.0.0 – 10.0.15.255 |
10.0.16.0 | 10.0.16.0 – 10.0.31.255 |
10.0.32.0 | 10.0.32.0 – 10.0.47.255 |
10.0.48.0 | 10.0.48.0 – 10.0.62.255 |
10.0.64.0 | 10.0.64.0 – 10.0.79.255 |
10.0.80.0 | 10.0.80.0 – 10.0.95.255 |
10.0.96.0 | 10.0.96.0 – 10.0.111.255 |
10.0.112.0 | 10.0.112.0 – 10.0.127.255 |
10.0.128.0 | 10.0.128.0 – 10.0.143.255 |
10.0.144.0 | 10.0.144.0 – 10.0.159.255 |
10.0.160.0 | 10.0.160.0 – 10.0.175.255 |
10.0.176.0 | 10.0.176.0 – 10.0.191.255 |
10.0.192.0 | 10.0.192.0 – 10.0.207.255 |
10.0.208.0 | 10.0.208.0 – 10.0.15.255 |
10.0.224.0 | 10.0.224.0 – 10.0.223.255 |
10.0.240.0 | 10.0.240.0 – 10.0.239.255 |
Example 2: IP Address : 192.168.100.154/27
Subnet Mask: 255.255.255.224 ( CIDR Notation /27)
11111111 | 11111111 | 11111111 | 11100000 |
Network Bits | Network Bits | Network | Nw Bits<->Host Bits |
192 Fixed | 168 Fixed | 100 Fixed |
So we have borrowed here 3 bits (red) from the 4th octet host bits& make it CIDR 27 instead of 24 (255.255.255.0) . Red underlined one is magic number 3rd one i.e. 32 from binary table.
192.168.100.154 Binary representation
192.168.100.154 | 11000000 | 10101000 | 01100100 | 10011010 |
255.255.255.224 | 11111111 | 11111111 | 11111111 | 11100000 |
Logical AND | 11000000 | 10101000 | 01100100 | 10000000 |
192 | 168 | 100 | 128 |
Network Address: 192.168.100.128, Broadcast Address: 192.168.100.159
- Total no of subnets = 2No of Subnets Bits = 23 = 8 Sub Networks
- Total no of IP in each sub network = 2No of Host Bits = 25 = 32
- Total no of usable IP in each sub network = 2No of Host Bits – 2= 30
- First IP address reserved for Network IP & Last for Broadcast IP for each subnet
Network Address | Range |
---|---|
192.168.100.0 | 192.168.100.0 – 192.168.100.31 |
192.168.100.32 | 192.168.100.32 – 192.168.100.63 |
192.168.100.64 | 192.168.100.64 – 192.168.100.95 |
192.168.100.96 | 192.168.100.96 – 192.168.100.127 |
192.168.100.128 | 192.168.100.128 – 192.168.100.159 |
192.168.100.160 | 192.168.100.160 – 192.168.100.191 |
192.168.100.192 | 192.168.100.192 – 192.168.100.223 |
192.168.100.224 | 192.168.100.224 – 192.168.100.255 |
Thanks!
Happy Learning! Your feedback would be appreciated!
Follow @shobhitsinghIN