1. Determine what class of network you have been given by the InterNIC. This tells you how many bits are fixed, and how many bits you can play with, as per the following table:
    Class A: 8 bits (1 octet) fixed, 24 bits for your use
    Class B: 16 bits (2 octets) fixed, 16 bits for your use
    Class C: 24 bits (3 octets) fixed, 8 bits for your use
    
    Example: 12.0.0.0 is class A, so we have 8 fixed, 24 free
    Example: 152.23.0.0 is class B, so we have 16 fixed, 16 free
    Example: 227.78.1.0 is class C, so we have 24 fixed, 8 free
    

     

  2. Determine how many subnets you wish to create or use. Remember that if you borrow N bits from the host field, you can create 2N subnets, and you can use 2N-2 subnets. You must leave at least 2 bits in the host field.

    Example 1: we need 20 usable subnets. The closest N such that 2N-2 >= 20 is N=5, giving 32 subnets, 30 useable. We must borrow 5 bits from the host field.

     

  3. Alternatively, determine how many hosts (maximum) you need on each subnet. If you leave N bits in the hosts field, then you can create 2N hosts on each subnet, of which 2N-2 hosts are useable. You must leave at least 2 bits in the host field.

    Example 2: we need 500 machines per subnet. The closest N such that 2N-2 >= 500 is N=9, giving 512 hosts per subnet, 500 useable. We must leave 9 bits in the host field.

     

  4. Now you know which bits are network and subnet bits, and which are hosts bits. To work out the subnet mask, turn all the network and subnet bits on, turn all the hosts bits off, and convert from binary to dotted decimal notation. Capital S below marks the lowest bit in the subnet field.

    Example 1: Assume given network is 12.0.0.0 (8 bits fixed), and we have borrowed 5 bits from the host field. We have:

    nnnn nnnn . ssss Shhh . hhhh hhhh . hhhh hhhh
    1111 1111 . 1111 1000 . 0000 0000 . 0000 0000
       255    .    248    .     0     .     0
    

    Example 2: Assume given network is 152.23.0.0 (16 bits fixed), and we have left 9 in the host field i.e borrowed 7 bits. We have:

    nnnn nnnn . nnnn nnnn . ssss ssSh . hhhh hhhh
    1111 1111 . 1111 1111 . 1111 1110 . 0000 0000
       255    .    255    .    254    .     0
    

     

  5. Work out the range of host numbers on each subnet. The lowest number is zero (all hosts bits off). Turn all hosts bits on and convert to decimal for the highest host number. If there are more then 8 hosts bits, work in octet groups.

    Example 1: We borrowed 5 bits from the 24 bits in the host field, leaving 19 bits in the host field. Host numbers range from:

    000 . 0000 0000 . 0000 0000		0.0.0    to
    111 . 1111 1111 . 1111 1111		7.255.255
    

    Example 2: We have 9 bits left in the host field. Host numbers range from:

    0 . 0000 0000				0.0	to
    1 . 1111 1111				1.255
    

     

  6. Work out the value of the lowest bit in the subnet field in decimal. Repetitively add this to the original network number to get the subnet numbers. These start at zero and go up by this value. If you cross an octet border, then the next octet goes up by one as required.

    Example 1: We borrowed 5 bits, creating 25 = 32 subnets. The lowest 1 bit in the network mask is worth 8 in the second octet. Therefore, we have subnets:

    12.0.0.0,   12.8.0.0,   12.16.0.0,  12.24.0.0,
    12.32.0.0,  12.40.0.0,  12.48.0.0,  12.56.0.0,
    12.64.0.0,  12.72.0.0,  12.80.0.0,  12.88.0.0,
    12.96.0.0,  12.104.0.0, 12.112.0.0, 12.120.0.0,
    12.128.0.0, 12.136.0.0, 12.144.0.0, 12.152.0.0,
    12.160.0.0, 12.168.0.0, 12.176.0.0, 12.184.0.0,
    12.192.0.0, 12.200.0.0, 12.208.0.0, 12.216.0.0,
    12.224.0.0, 12.232.0.0, 12.240.0.0, 12.248.0.0
    
    The first and last subnet are unusable.

    Example 2: We borrowed 7 bits, creating 27 = 128 subnets. The lowest 1 bit in the network mask is worth 2 in the third octet. Therefore, we have subnets:

    152.23.0.0, 152.23.2.0,   152.23.4.0,   .....
    ....      , 152.23.252.0, 152.23.254.0
    
    The first and last subnet are unusable.

     

  7. For each subnet, add on the host range to find out the full network numbers for every host on that subnet. The first and last host number on each network is unusable. Count subnets from #1, #2, #3 onwards.

    Example 1: nb. All hosts have netmask 255.248.0.0

    Subnet			    Host Range			Net #
    12.0.0.0	12.0.0.0	to	12.7.255.255	#1
    12.8.0.0	12.8.0.0	to	12.15.255.255	#2
      ...
    12.240.0.0	12.240.0.0	to 	12.247.255.255	#31
    12.248.0.0	12.248.0.0	to	12.255.255.255	#32
    

    Example 2: nb. All hosts have netmask 255.255.254.0

    Subnet			    Host Range			Net #
    152.23.0.0	152.23.0.0	to	152.23.1.255	#1
    152.23.2.0	152.23.2.0	to	152.23.3.255	#2
      ....
    152.23.252.0	152.23.252.0	to	152.23.253.255	#127
    152.23.254.0	152.23.254.0	to	152.23.255.255	#128
     
    ------------------------------------------------------------------------------------------------------------------

    subnet mask:

    The subnet mask (formal term: extended network prefix), is not an address, but determines which part of an IP address is the network field and which part is the host field. A subnet mask is 32 bits long and has 4 octets, just like an IP address.

    To determine the subnet mask for a particular subnetwork IP address follow these steps.

    (1) Express the subnetwork IP address in binary form.

    (2) Replace the network and subnet portion of the address with all 1s.

    (3) Replace the host portion of the address with all 0s.

    (4) As the last step convert the binary expression back to dotted-decimal notation.

    Note: The extended network prefix includes the class A, B, or C network number, plus the subnet field (or subnet number) that is being used to extend the routing information (which is otherwise just the network number).

 

Address Class

Size of Default Host Field

Maximum Number of Subnet Bits

A

24

22

B

16

14

C

8

6

128

64

32

16

8

4

2

1

 

1

0

0

0

0

0

0

0

128

1

1

0

0

0

0

0

0

192

1

1

1

0

0

0

0

0

224

1

1

1

1

0

0

0

0

240

1

1

1

1

1

0

0

0

248

1

1

1

1

1

1

0

0

252

1

1

1

1

1

1

1

0

254

1

1

1

1

1

1

1

1

255