Overview

IPv4 Addressing

Every device on the Internet needs a unique address to communicate with each other. This address is called the Internet Protocol (IP) Address.

An IPv4 address is 32 bits long -- thirty-two 1s and 0s. For example:

IPv4 Address 192.168.0.1
Decimal19216801
Binary1100 00001010 10000000 00000000 0001

and is expressed in 4 doted octets format. An (unsigned) octet is 8 bits in size thus the smallest value (where all 8 bits are 0) is 0 (in decimal) while the largest value (while all 8 bits are 1) is 255.

IPv6 address however is 128 bits long and is expressed in 8 groups of 4 hexadecimal digits. A hexadecimal digit can hold up to 16 unique values thus it is represented in 0 (when all 4 bits are 0) and F (when all 4 bits are 1).

IP prefix is an IP address expressed in CIDR notation. It carries two (2) information important information for routers on the internet to be able to deliver the traffic to its destination. These information are: (a) Network ID (or network prefix) and (b) Host ID. Network ID represents which network the address belongs to while Host ID represents end device (within the network) it is intended for. Keep in mind that the last address in a network is used as broadcast address (sending traffic to all the hosts within the same network).

The prefix in CIDR notation indicates the number of bits (from left to right) is used to identify the network. Following are examples of IPv4 prefix in CIRD notation:

Example 1: a prefix of 192.168.0.1/24 dictates that the first 24 bits represents the network while the remaining 8 (32-8) bits represents the host. In this case Network ID is 192.168.0.0 and the host address starts from 192.168.0.0 and ends at 192.168.0.254 (.255 is broadcast).

Example 2: a prefix of 192.168.0.129/25 dictates that the first 25 bits represents the network and therefore the Network ID is 192.168.0.128 and the host address starts from 192.168.0.129 and ends at 192.168.0.254 (.255 is broadcast). This is because the first 25 bits of 192.168.0.129 (11000000.10101000.00000000.10000001) summed up to 192.168.0.128 (11000000.10101000.00000000.10000000).

Example 3: a prefix of 192.168.3.88/23 dictate that the first 23 bits represents the network and therefore the Network ID is 192.168.2.0 and the host address starts from 192.168.2.1 and ends at 192.168.3.254 (.255 is broadcast). This is because the first 23 bits of 192.168.3.88 (11000000.10101000.00000011.00101100) summed up to 192.168.2.0 (11000000.10101000.00000010.00000000).

Example 4: a prefix of 192.168.123.123/32 dictates that the first 32 bits represents the network and therefore both the Network ID and Host ID will be 192.168.123.123.

While it is true that any IP address (if it follows the rules above) can be used as valid IP address, however some of the addresses are reserved for special purpose. Table below lists all the IP prefixes that have special purpose are not routable over the internet.

PrefixDescription
0.0.0.0/8"This" network
10.0.0.0/8Private-use networks
100.64.0.0/10Carrier-grade NAT
127.0.0.0/8Loopback
127.0.53.53Name collision occurrence
169.254.0.0/16Link local
172.16.0.0/12Private-use networks
192.0.0.0/24IETF protocol assignments
192.0.2.0/24TEST-NET-1
192.168.0.0/16Private-use networks
198.18.0.0/15Network interconnect device benchmark testing
198.51.100.0/24TEST-NET-2
203.0.113.0/24TEST-NET-3
224.0.0.0/4Multicast
240.0.0.0/4Reserved for future use
255.255.255.255/32Limited broadcast

Below is a table to inter-convert between CIDR and sub net mask:

CIDR prefixSub net maskNumber of IP addresses
/00.0.0.04,294,967,296
/1128.0.0.02,147,483,648
/2192.0.0.01,073,741,824
/3224.0.0.0536,870,912
/4240.0.0.0268,435,456
/5248.0.0.0134,217,728
/6252.0.0.067,108,864
/7254.0.0.033,554,432
/8255.0.0.016,777,216
/9255.128.0.08,388,608
/10255.192.0.04,194,304
/11255.224.0.02,097,152
/12255.240.0.01,048,576
/13255.248.0.0524,288
/14255.252.0.0262,144
/15255.254.0.0131,072
/16255.255.0.065,536
/17255.255.128.032,768
/18255.255.192.016,384
/19255.255.224.08,192
/20255.255.240.04,096
/21255.255.248.02,048
/22255.255.252.01,024
/23255.255.254.0512
/24255.255.255.0256
/25255.255.255.128128
/26255.255.255.19264
/27255.255.255.22432
/28255.255.255.24016
/29255.255.255.2488
/30255.255.255.2524
/31255.255.255.2542
/32255.255.255.2551