A Subnet Mask separates the IP address into the Network ID and Host ID. Similar to IP address, subnet mark uses a 32-bit address space, which limits the number of unique hosts to 2^32. Each Subnet Maskcontains 4 bytes (called octet, separated by dots), each byte contains 8 bits.
Because network ID is define by AND operator, we have:
– All bits of “1” in Subnet Mask define bits in IP address for Network ID.
– All bits of “0” in Subnet Mask define bits in IP address for Host ID.
For example:
IP: 1100000.10101000.00000010.11111110 (192.168.2.254)
Mask: 1111111.11111111.11111111.00000000 (255.255.255.0)
————————————————————————————————-
Network ID: 1100000.10101000.00000010.00000000 (192.168.2.0)
With 8 bits of
“0” in the end of Subnet Mask, that means there are total 2^8=256 IP
address (255 usable) in this network, from 192.168.2.1(00000001) to
192.168.2.255(11111111).
Another way to determine Network ID is using Prefix
Length, which is write after the IP address in demical form and
separated by “/”. Prefix
Length shows how many bits from left to right of IP address in binary
form is used for Network ID.
For example:
IP: 192.168.2.254/25
There are 25 bits is used for Network ID, therefore we have:
IP: 1100000.10101000.00000010.11111110 (192.168.2.254)
Mask: 1111111.11111111.11111111.11000000 (255.255.255.192)
————————————————————————————————–
Network ID: 1100000.10101000.00000010.11000000 (192.168.2.192)
With 7 bits of
“0” in the end of Subnet Mask, that means there are total 2^6=128 IP
address in this network (127 usable), from 192.168.2.193(11000001)/25 to
192.168.2.255(11111111)/25.
Note:
If we devide the network 192.168.2.0 /24 into 2 separately networks, they will be:
192.168.2.0 /25 contains 128 IPs from .0 to .127
192.168.2.128 /25 contains 128 IPs from .128 to .255
And in the case of 4 separately networks, they
will be:
192.168.2.0 /26 contains 64 IPs from .0 to .63
192.168.2.64 /26 contains 64 IPs from .64 to .127
192.168.2.128 /26 contains 64 IPs from .128 to .191
192.168.2.192 /26 contains 64 IPs from .192 to .255
T. V. Quoc

