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:
|| border=1 width=100%25 class="sortable simpletable"
||# IPv4 Address 192.168.0.1 ||
|| Decimal || 192 || 168 || 0 || 1 ||
|| Binary || 1100 0000 || 1010 1000 || 0000 0000 || 0000 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.
|| border=1 width=100%25 class="sortable simpletable"
||# Prefix ||# Description ||
|| 0.0.0.0/8 || "This" network ||
|| 10.0.0.0/8 || Private-use networks ||
|| 100.64.0.0/10 || Carrier-grade NAT ||
|| 127.0.0.0/8 || Loopback ||
|| 127.0.53.53 || Name collision occurrence ||
|| 169.254.0.0/16 || Link local ||
|| 172.16.0.0/12 || Private-use networks ||
|| 192.0.0.0/24 || IETF protocol assignments ||
|| 192.0.2.0/24 || TEST-NET-1 ||
|| 192.168.0.0/16 || Private-use networks ||
|| 198.18.0.0/15 || Network interconnect device benchmark testing ||
|| 198.51.100.0/24 || TEST-NET-2 ||
|| 203.0.113.0/24 || TEST-NET-3 ||
|| 224.0.0.0/4 || Multicast ||
|| 240.0.0.0/4 || Reserved for future use ||
|| 255.255.255.255/32 ||Limited broadcast ||
Below is a table to inter-convert between CIDR and sub net mask:
|| border=1 width=100%25 class="sortable simpletable"
||# CIDR prefix ||# Sub net mask ||# Number of IP addresses ||
|| /0 || 0.0.0.0 || 4,294,967,296 ||
|| /1 || 128.0.0.0 || 2,147,483,648 ||
|| /2 || 192.0.0.0 || 1,073,741,824 ||
|| /3 || 224.0.0.0 || 536,870,912 ||
|| /4 || 240.0.0.0 || 268,435,456 ||
|| /5 || 248.0.0.0 || 134,217,728 ||
|| /6 || 252.0.0.0 || 67,108,864 ||
|| /7 || 254.0.0.0 || 33,554,432 ||
|| /8 || 255.0.0.0 || 16,777,216 ||
|| /9 || 255.128.0.0 || 8,388,608 ||
|| /10 || 255.192.0.0 || 4,194,304 ||
|| /11 || 255.224.0.0 || 2,097,152 ||
|| /12 || 255.240.0.0 || 1,048,576 ||
|| /13 || 255.248.0.0 || 524,288 ||
|| /14 || 255.252.0.0 || 262,144 ||
|| /15 || 255.254.0.0 || 131,072 ||
|| /16 || 255.255.0.0 || 65,536 ||
|| /17 || 255.255.128.0 || 32,768 ||
|| /18 || 255.255.192.0 || 16,384 ||
|| /19 || 255.255.224.0 || 8,192 ||
|| /20 || 255.255.240.0 || 4,096 ||
|| /21 || 255.255.248.0 || 2,048 ||
|| /22 || 255.255.252.0 || 1,024 ||
|| /23 || 255.255.254.0 || 512 ||
|| /24 || 255.255.255.0 || 256 ||
|| /25 || 255.255.255.128 || 128 ||
|| /26 || 255.255.255.192 || 64 ||
|| /27 || 255.255.255.224 || 32 ||
|| /28 || 255.255.255.240 || 16 ||
|| /29 || 255.255.255.248 || 8 ||
|| /30 || 255.255.255.252 || 4 ||
|| /31 || 255.255.255.254 || 2 ||
|| /32 || 255.255.255.255 || 1 ||