blog
blog copied to clipboard
IP Addressing, CIDR, and Subnet Mask
1. Classless Inter-Domain Routing (CIDR)
CIDR was introduced to overcome the limitations of class-based addressing (Classful network). It allows for more flexible IP address allocation by using variable-length subnet masks. CIDR notation (e.g., /24
) indicates the number of bits used for the network portion of the address. The remaining bits are used for host addresses within that network.
Examples Calculation with CIDR
Consider the IP address 192.168.1.0/24
:
-
Network Portion:
192.168.1
(first 24 bits) -
Host Portion:
0
to255
(last 32 - 24 = 8 bits) - Total Addresses: 28 = 256
IP Range:
-
Starting Address:
192.168.1.0
-
Ending Address:
192.168.1.255
-
Usable Addresses:
192.168.1.1
to192.168.1.254
(256 addresses minus 2 reserved for network and broadcast addresses)2 addresses are reserved:
- The first address (
192.168.1.0
) is the network address. - The last address (
192.168.1.255
) is the broadcast address.
- The first address (
Consider the IP address 10.0.0.0/16
:
-
Network Portion:
10.0
(first 16 bits) -
Host Portion:
0.0
to255.255
(last 32 - 16 = 16 bits) - Total Addresses: 216 = 65,536
IP Range:
-
Starting Address:
10.0.0.0
-
Ending Address:
10.0.255.255
-
Usable Addresses:
10.0.0.1
to10.0.255.254
(65,536 addresses minus 2 reserved for network and broadcast addresses)
2. Subnet Mask
A subnet mask is a 32-bit number that separates the network portion of the IP address from the host portion. It determines which part of an IP address is used to identify the network and which part identifies the host within that network.
Example: 192.168.1.0/24
-
IP Address:
192.168.1.0
-
CIDR Notation:
/24
- The
/24
indicates that the first 24 bits are used for the network portion. - The remaining 8 bits (32-24=8) are used for the host portion.
- The
Subnet Mask Calculation:
-
Binary Representation:
11111111.11111111.11111111.00000000
-
Decimal Representation:
255.255.255.0
Subnet masks are also expressed in dot-decimal notation like an IP address. The prefix 192.168.1.0/24
have the subnet mask 255.255.255.0
.
In this example, the subnet mask 255.255.255.0
tells us that the first three octets (192.168.1
) represent the network, while the last octet is used for hosts within that network.