We can find Subnet Mask from any below information available.
How to find Subnet Mask from prefix?
Prefix or CIDR Netmask represents network part.
So, Network Bits = Prefix #Subnet Mask is 32 bits binary number. Which consists of Network Bits and Host Bits.
SM = 32 and NB = prefix#SM = NB + HB
SM = prefix# + HBTo find Subnet Mask form 32 bit binary number which has consicutive prefix# times '1' and remaining bits as 0 Divide this binary number in 4 octets and convert octets to decimal format.
Example:Subnet Mask for /23 network
Write 23 times consecutive '1' as Prefix# = 23 SM = 11111111111111111111111 Now append consecutive '0' HB times with SM. here HB = 9. SM = 11111111111111111111111000000000 Divide in 4 octets SM = 11111111.11111111.11111110.00000000 Convert octets to decimal SM = 255.255.254.0How to find Subnet Mask from Network Bits or Host Bits?
As mentioned before Subnet Mask is 32 bits binary number. Which consists of Network Bits and Host Bits.
SM = NB + HB
To find Subnet Mask form 32 bit binary number which has consicutive prefix# times '1' and remaining bits as 0 Divide this binary number in 4 octets and convert octets to decimal format.
Example:Subnet Mask for Network Bits 25 or Host Bits 7
Write 25 times consecutive '1' as NB = 25 SM = 1111111111111111111111111 Now append consecutive '0' HB times with SM. here HB = 7. SM = 11111111111111111111111110000000 Divide in 4 octets SM = 11111111.11111111.11111111.10000000 Convert octets to decimal SM = 255.255.255.128How to find Subnet Mask from Wildcard Mask?
Subnet Mask is inverted number of Wildcard Mask.
SM = ~ WM
Example:Subnet Mask for Wilcard Mask 0.0.0.127
Write Wilcard Mask in binary WM = 00000000.00000000.00000000.01111111 Subnet Mask is inverted binary of Wildcard Mask. SM = 11111111.11111111.11111111.10000000 Convert octets to decimal SM = 255.255.255.128How to find Subnet Mask from Class information?
Classful IP address allocating scheme were designed on basic of predefined block of IP ranges.
Default Subnet Mask for classes are as below
Class | Subnet Mask |
---|---|
A | 255.0.0.0 |
B | 255.255.0.0 |
C | 255.255.255.0 |