04/11/2022
IP subnetting is a very interesting topic.
Let me explain something.
Using an example:
We have an IPv4 address: 192.168.1.0 and a subnet mask: 255.255.255.0
This can be written as 192.168.1.0/24 whereby /24 represents the network portion of the address.
This can be represented as:
192. 168. 1. 0
110000000. 10101000. 00000001. 00000000
255. 255. 255. 0
11111111. 11111111. 11111111. 00000000
To get the network address, we use the logical AND:
11000000. 10101000. 00000001. 00000000
11111111. 11111111. 11111111. 00000000
11000000. 10101000. 00000001. 00000000
The network address in binary is:
11000000. 10101000. 00000001. 00000000
Converting this to decimal gives us:
192. 168. 1. 0
Therefore, the network address in decimal is:
192.168.1.0
Now, let us subnet it.
Let us borrow one bit from the host portion of the subnet mask.
11111111. 11111111. 11111111. 00000000
becomes:
11111111. 11111111. 11111111. 10000000
Convert this to binary:
255. 255. 255. 128
How do we get 128?
Remember the binary table:
128. 64. 32. 16. 8. 4. 2. 1
2⁷. 2⁶. 2⁵. 2⁴. 2³. 2². 2¹. 2⁰
The last octet of our subnet mask is:
1. 0. 0. 0. 0. 0. 0. 0
The 1 is in the place of 128
Now, the no. of hosts is 2 (raised to the power of the number of 0s in that last octet)
No.of hosts = 2⁷ = 128
No.of usable hosts = 128 - 2 = 126
The 2 we are subtracting, 1 bit is for network address, the other bit is reserved for broadcast address.
No. of subnetworks = 2 (raised to the power of the number of 1s in the last octet)
No.of subnetworks = 2¹ = 2
The