IP's & CIDR notation
-
Intro
An IP address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. It consists of two parts: the network portion and the host portion. The network portion identifies the network that the device is part of, while the host portion identifies the device itself within the network.
CIDR
In CIDR notation, the number after the slash (/) represents the number of bits used for the network portion of the address. This is known as the prefix.
For example, a network prefix of /24 means that the first 24 bits of the IP address represent the network portion, and the last 8 bits represent the host portion. In binary, this would look like:
Network portion:
11111111.11111111.11111111.00000000
Host portion:
00000000
The lowest IP address in the subnet would be the one with all zero host bits:
11111111.11111111.11111111.00000000
The highest IP address would be the one with all one host bits:
11111111.11111111.11111111.11111111
Subnet examples
/24
For example, consider the following IP address written in
CIDR notation:192.168.0.0/24
Prefix: /24
Lowest IP: 192.168.0.0
Highest IP: 192.168.0.255
Possible hosts: 256In this case, the prefix is /24, which means that the first 24 bits of the address are used for the network portion, and the last 8 bits are used for the host portion. There are 2^8 (256) possible values for the host portion, which corresponds to the number of hosts that can be part of the network.
/16
On the other hand, consider the following IP address written in CIDR notation:
10.0.0.0/16
Prefix: /16
Lowest IP: 10.0.0.0
Highest IP: 10.0.255.255
Possible hosts: 65,536In this case, the prefix is /16, which means that the first 16 bits are used for the network portion, and the last 16 bits are used for the host portion. There are 2^16 (65,536) possible values for the host portion, or a larger number of hosts that can be part of the network.
In general, a larger prefix (e.g. /24) means that there are fewer hosts that can be part of the network, while a smaller prefix (e.g. /16) means that there are more hosts that can be part of the network.