TH 08 ‐ Calculating IP and Subnets Manually - gautam-amitesh/OCI GitHub Wiki
Internet Protocol version 4 (IPv4) is a unique 32-bit number, divided into four segments using a period (.) for better readability. This means each segment consists of 8 bits, and in networking, a group of 8 bits is called an octet. In machine language, a bit is a physical state of a transistor that can only be off (0) or on (1).
Since an IPv4 address consists of 32 bits, and each bit can have two possible values (0 or 1), the total number of possible combinations in an octet is 28 (256), and in a 32-bit number it is 232 (4,294,967,296).
If a bit contains a value of 1 (on), then the decimal equivalent is 2n, where n is the index (0 to n) of the bit calculated from the right side. If the value is 0 (off), then the decimal equivalent is 0. To calculate the decimal value of a binary number with multiple bits, add all the decimal equivalents for every bit.
The above diagram also shows how an 8-bit number starts from 0 and goes up to 255, and why this limit is not from 1 to 256.
Using Subnet Masking, we freeze a particular part of a 32-bit IP address, and then we get unique IPs using the leftover unfrozen part. For example, if we have an IP address 10.0.0.0 and we freeze the first 24 bits, we are left with 8 bits. By manipulating these 8 bits, we can obtain 256 unique combinations of IP addresses.