OCI ‐ TH 7 ‐ Calculating IP and Subnets Manually - sayan028/Sayan-Chakraborty-OCI GitHub Wiki
Every server needs an IP address to communicate with another server.
An IP address is needed whether the communication is:
- Internal
- Public / Internet level
An IP address is made up of four octets.
Example:
10.0.0.0
Each octet contains 8 bits.
┌─────────┬─────────┬─────────┬─────────┐ │ Octet 1 │ Octet 2 │ Octet 3 │ Octet 4 │ │ 8 bits │ 8 bits │ 8 bits │ 8 bits │ └─────────┴─────────┴─────────┴─────────┘
Each octet can contain a combination of binary numbers.
- Decimal Number - 0, 1, 2, 3 ...
- Binary Number - 0 or 1
Each value is obtained by multiplying the previous value by 2:
1 × 2 = 2 2 × 2 = 4 4 × 2 = 8 8 × 2 = 16 16 × 2 = 32 32 × 2 = 64 64 × 2 = 128
Therefore, one octet can use the following binary place values:
2⁷ 2⁶ 2⁵ 2⁴ 2³ 2² 2¹ 2⁰ 128 64 32 16 8 4 2 1
There are 8 digits/bits in one octet.
An IP address can be represented using binary numbers.
For example:
0 0 0 0 0 0 0 0
The corresponding place values are:
2⁷ 2⁶ 2⁵ 2⁴ 2³ 2² 2¹ 2⁰
When a bit is changed from 0 to 1, its corresponding value is added.
For example:
00000001
means:
1 = 2⁰
Similarly:
00000010
means:
2 = 2¹
And:
00000011
means:
2 + 1 = 3
If the IP starts from:
0.0.0.0
the IP addresses increase sequentially:
0.0.0.0 0.0.0.1 0.0.0.2 0.0.0.3 ... 0.0.0.255
After reaching 255 in the last octet, the next IP becomes:
0.0.1.0
Then:
0.0.1.1 0.0.1.2 ... 0.0.1.255
The calculation therefore moves to the next octet after the previous octet reaches its limit.
Subnet masking determines which octets are fixed and which octets can be changed.
10.0.0.18
Here, we mask/fix the first octet:
[10].0.0.18
The first octet is fixed.
10.0.0.16
Here, we mask/fix the first and second octets:
[10.0].0.16
The first two octets are fixed.
10.0.0.24
Here, we mask/fix the first three octets:
[10.0.0].24
The first three octets are fixed.
For every condition, the unfrozen octets can be edited.
For example:
[10].0.0.18
Only the first octet is fixed, while the remaining octets can be changed.
Similarly:
[10.0].0.16
The first two octets are fixed.
And:
[10.0.0].24
The first three octets are fixed.
- An IP address consists of four octets.
- Each octet contains 8 bits.
- Each bit represents a power of 2.
-
The powers of 2 from
2⁰to2⁷are used to calculate the value of an octet. - IP addresses increase sequentially.
-
When the last octet reaches
255, the next octet increases. - Subnet masking fixes specific octets.
- The unfrozen octets can be edited according to the subnet condition.