Subnetting becomes an important topic in networks.This is core of networks how network addresses are being assigned.Students find difficulty in solving the questions on subnetting. This article will help you to solve questions on subnetting.

Free All India Test Equipped with Artificial Intelligence

Start Test  



There are currently five different field patterns in use, each defining a class of addresses. The different classes are designed  to cover the needs of different types of organisations.An IPV4 Address is represented by 32 bits. Division of bits is done on the basis according to class type. A part of address denotes network ID. Another part denotes host ID.

Class A,B,C are used for addressing.The first octet determines the type of class.

                     0-127     →  Class A

                    128-191 →  Class B

                    192-223 →  Class C

                    234- 239 → Class D

                    240- 255 → Class E

 must read : 6 Month Study Plan/TimeTable To Crack GATE (CS) 2017 By Experts

Allocation of Host and Network Id In Classes



In class A first bit 0 is fixed , for class B two bit 10 is fixed , for class C three bits 110 is fixed. As shown above in class A first 8 bits are reserved for network id and 24 for host id. In class B first 16 bits are reserved for network id and next 16 bits are reserved for host id. Class D and Class E is not in use. So no allocation of network and host bits.


As above there are 2 levels of hierarchy, network and host. Subnet introduces third level of hierarchy, network, subnet and host.

                             network id   host id


                                                    subnet id and host id

It means host id  is further divided into subnet and host.

For eg:- in class A first 8 bits are reserved for network id, the next 24 bits can be divided  into subnet id and host ID.

To have subnet of IP address we use subnet mask.

Also read : Best Books for GATE-CSE by Toppers

Subnet Mask

A subnet mask is sequence of 1 & 0’s which determines which  is subnet id to host id.

                                      classes        Mask

                                      Class A  ->

                                      Class B  ->

                                      Class C  ->


Types of Subnet Mask

Subnet Mask can be two types : Natural  and customed. Natural mask are mask defined above for class A,class B,class C. Customed mask is used to determine according to needs, what is subnet id and host id.

Example: suppose is network address

Natural mask should be

If use custom

                  10→ network id

                   5→ subnet id

                  0.20 → host id (16 bits for host id, if we have used natural mask then we we had 24 bits for host id. Customed mask enables to assign subnets according to requirements of organization)


Free Stimulation Mock Test For GATE 2017
Start Test

Tips To Remember


                  -------------------and-----------    =>


[Mask only does ‘and’ operation and we get starting address of network]


The bytes in IP address that correspond to 255 in mask will be repeated in subnetwork address

          ip address                 45    20   25  0

         mask                         255    0     0   0


                                           45     0     0    0


  The bytes in IP address that correspond to 0 in mask will change 0 in subnetwork  address as shown above


For other bytes, use network and operator

   IP address.          45           123         21           8

   Mask                     255         192         0              0

                                   45           64           0              0



          The number after slash, Determines number of left mask bits to be used for network mask.

                                      for this subnet mask will be  11111111.11111111.11000000.00000000


                 The number of host address is 2host id – 2

for example, In class A the number of host address is 224 – 2

                 and  Number of network addresses is  28 – 2 


To determine mask of variable number we check the number of subnet and the number of host per network required

                                                   2x – 2 = subnets

where, x is number of subnet bit in mask

                                                       2x – 2 = host

x is number of host bit in mask

 Also read : Tips to Solve Asymptotic Notation Questions in GATE - CS

Questions From GATE


A company has a class C network address of It wishes to have three subnets, one with 100 hosts and two with 50 hosts each. Which one of the following represents a feasible set of subnet address/subnet mask pairs?


  1. 204.204.128/


  1. 204.204.0/


  1. 204.204.128/


  1. 204.204.128/



Since it is class C, we can create subnetting in last octet only. First 3 octet are fixed

In last octet

we need 2 subnets,

128 host address

128 host address

The second subnet of 128 host address can be further divided into 2 blocks of 64 address each that will fulfill our requirement

The address range in lass octet can start from



We can treat this as 2 blocks

  • Let us consider 10000000 – 11111111] to 1 block of 128 address


  • In next block 00000000, it is further divided into 2 blocks of which first 2 bits are



It can be written as

                 01000000] 64

                 00000000] 0

Mask (here 2 bits are fixed)        '00'      '01'

when one bit is fixed ,

mask is                '10000000'     

The no. of addresses are 256-128= 128

when two  bit is fixed

mask is


The no. of addresses are = 256-192= 64


                               Hence answer is d

Also read : Frequently asked Questions For Gate Computer Science Interview


Find the net id and host id for each address

  1. 23.145.90
  2. 34.78.7
  3. 7.3.8
  4. 6.8.4
  5. 76.9.23


First find the class and then find the net id and host id

  1. Class A, net id:4 host id 23.145.90
  2. Class D, no host id or net id
  3. Class E, no host id or net id
  4. Class B, net id:129.6 host id 8.4
  5. Class C, net id:198.76.9 host id 23



The address of a class is to be split into subnet with 6 – bit subnet number. What is the maximum number of subnets and the maximum number of hosts in each subnet?

  1. 62 subnets and 262142 hosts
  2. 64 subnets and 262142 hosts
  3. 62 subnets and 1022 hosts
  4. 64 subnets and 1024 hosts



The class B is defined as follows

0                              16           31

1              0              net id    host id

The maximum number of subnet = 26 – 2 = 62

The maximum number of host in each subnet = 210 =1024 – 2 = 1022


 Best Wishes !!


Enroll in Mentor Program and Avail your Personalized Mentor for GATE 2017 Preparation and Doubts Clarification!

What aspirants need is the right approach along with concrete strategies to reach their goals. GATE GUARANTEE PACK has been the choice of successful GATE toppers all over India.

It is the perfect online tool to check your level of preparedness among st students preparing all over the country where you study under guidance of mentors.

Free Stimulation Mock Test For GATE 2017
Start Test


Search on PrepLadder