What is Subnet Mask?
An IP address has
two components, the network address and the host address. A subnet mask
separates the IP address into the network and host addresses
(<network><host>). Subnetting further divides the host part of an
IP address into a subnet and host address
(<network><subnet><host>) if additional subnetwork is needed.
It is called a subnet mask because it is used to identify network address of an
IP address by perfoming a bitwise AND operation on the netmask.
A Subnet mask is a 32-bit number that masks an IP
address, and divides the IP address into network address and host address.
Subnet Mask is made by setting network bits to all "1"s and setting
host bits to all "0"s. Within a given network, two host addresses are
reserved for special purpose, and cannot be assigned to hosts. The
"0" address is assigned a network address and "255" is
assigned to a broadcast address, and they cannot be assigned to hosts
How to calculate
Subnet Mask?
Consider IP address 192.168.2.0 is divided into 4 subnets i.e. 192.168.2.0, 192.168.2.64, 192.168.2.128, 192.168.2.192 networks.
Now we have to calculate subnet mask for above four networks to identify each
network or we can say to identify the destination network to which packet
belongs. If we see our address it belongs to class C address. From class C
network address first three octet is network id and last octet is host id.
So first step
to calculate subnet mask is to make all network id bits to 1
11111111 .
11111111 . 11111111 . 00000000
Second Step: For sub
netting we have borrowed first two bits from last octet i.e. from host id. Make
that two bits to 1. After making 1 address is
11111111 .
11111111 . 11111111 . 11000000
Now this your subnet mask for given address and in
decimal form 255.255.255.192.
How to find an IP
address belongs to which sub network?
Now we have seen how to find subnet mask but it is
important to find how it works?. Now consider an IP address 192.168.2.75. To find it follow some
steps
Step 1: Convert
an IP address in binary
11000000 . 10101000
. 00000010 . 01001011
Step 2: Do
Logical AND operation with subnet mask
11000000 . 10101000
. 00000010 . 01001011
11111111 .
11111111 . 11111111 . 11000000
11000000 . 10101000 . 00000010 . 01000000
i.e. 192.168.2.64 this is network address for 192.168.2.75