Subnetting Class B

In this article we will understand IPv4 Class B subnetting. Let's begin by understanding basic definitions.
 
Definition of IP Address:  An IP address is a 32 bit number that logically defines a host. IP address assigned to a LAN card or a device interface can change based on network admin's requirement.

Definition of Subnet Mask: Subnet Mask is a 32 bit value that defines which portion of an IP address is network and which portion is host.

Definition of Subnetting and its requirement: Subnetting is extending the network portion and reducing the host portion. Advantage of Subnetting is that helps a network admin to efficiently use the network IPs.

Before understanding Class B subnetting in detail, it is advised to have clear understanding of  Subnetting Class C


Let's take example of a Class B Network 172.16.0.1/16. We will subnet this network from 172.16.0.0/16 till 172.16.0.254/30. Kindly note that default subnet mask of  Class B is /16 (or 255.255.0.0).

Kindly note that subnet mask 255.255.0.0 can be written as /16.   We can write /16 in binary as  11111111.11111111. 00000000.00000000. Here, number of 1s is 16 and we use this value to denote the subnet mask as /16. In Class B network shown above, we will have 16 Network bits (1s) and 16 host bits (0s) and using subnetting we will extend  the network portion from  172.16.0.0/16 till 172.16.0.0/30. 


Subnetting Class B (172.16.0.0/17)

Let's begin subnetting by borrowing 1 bit (Most significant bit) from host portion and use it in the network portion.  The subnet mask will become /17 (previous value was /16).

Also note that the last 2 octets (3rd and 4th octets) of network 172.16.0.0 can be written as 00000000.00000000

While we change subnet mask from /16 to /17, the binary value of  3rd  octet of subnet mask can be written as 10000000 while the binary value of 4th octet will remain 00000000. The Decimal value of subnet mask will become 255.255.128.0, because the decimal value of  10000000 in 3rd Octet is 128.

Let assume the number of bits we have made turned '1' or borrowed = N( ex. Network bit),  so here N= 1

Let assume the number of bits left zero(remaining) = H (ex. Host bit), so here H = 15.

The binary format of 3rd  and 4th octet will be : 10000000.00000000 (7 bits of 3rd Octet are 0 and all 8 bits of 4th octet are 0. So 7+8 = 15)

Formulas to calculate number of subnets and hosts per subnet:

  • Number of subnets   =  2N
  • Number of hosts per subnet =  (2H)   - 2
  • Block size of each subnet =  256 - Decimal value of  new mask.


Subnetting Class B (172.16.0.0/17)


Based on above rules let's calculate the values for 172.16.0.0/17
  • Number of subnets (for /25 mask)  =  2N   
                    N = 1, so 21   =  2 ,  So Number of subnets (for /25 mask) = 2
                   We will also discuss about range/value/block size of these subnets in this article shortly.

  • Number of hosts per subnet =  (2H)   - 2  
                   H is 7, so 215 - 2 
                  Hosts per subnet = 32768 - 2 = 32766.
       
  • Block size of each subnet =  256 - 128  = 128

For /17 mask, we will get 2 subnets, each with 32766 hosts. Below is list of 2 subnets:
  •     1st  Subnet  = 172.16.0.0/17
  •     2nd  Subnet = 172.16.128.0/17

Below is list of range of IP address of these subnets.
  •     For 1st  Subnet, 1st valid IP is 172.16.0.1/17, last valid IP is 172.16.127.254/17, and broadcast IP is 172.16.127.127/17
  •     For 2nd  Subnet, 1st valid IP is 172.16.128.1/17, last valid IP is 172.16.255.254/17, and broadcast IP is 172.16.255.255/17


Subnetting Class B (172.16.0.0/23)

With mask /23, subnet mask will be 255.255.254.0.  Binary value of 3rd  octet is 11111110 and 4th Octet is 00000000. Using this let’s proceed further.
  • Number of subnets (for /23 mask)  =  2N      
              N = 7,  (2 bits are borrowed from host portion), so 27  =  128
              Number of subnets (for /23 mask) = 128

  • Number of hosts per subnet =  (2H)   - 2     
             H is 9, (1 zero from 3rd octet and 8 zero bits from 4th octet are available for host portion), so 29  - 2.
             Hosts per subnet = (512 -2) = 510.


  • Block size of each subnet =  256 - 254  = 2

For /23 mask, we will get 128 subnets, each with 510 hosts, each subnet has block size of 2. Below is list of all 128 subnets.
  • 1st  Subnet  = 172.16.0.0/23
  • 2nd  Subnet = 172.16.2.0/23
  • 3rd  Subnet = 172.16.4.0/23
  • 4th  Subnet = 172.16.6.0/23



  • 127th  Subnet=172.16.252.0/23
  • 128th  Subnet=172.16.254.0/23

 Below is list of range of IP address of these subnets.:
  •  For 1st  Subnet, 1st valid IP is 172.16.0.1/23, last valid IP is 172.16.1.254/23, and broadcast IP is 172.16.1.255/23
  •  For 2nd  Subnet, 1st valid IP is 172.16.2.1/25, last valid IP is 172.16.3.254/23, and  broadcast IP is 172.16.3.255/23
  •  For 3rd  Subnet, 1st valid IP is 172.16.4.1/23, last valid IP is 172.16.5.254/23, and broadcast IP is 172.16.5.255/23
  •  For 4th  Subnet, 1st valid IP is 172.16.6.1/23, last valid IP is 172.16.7.254/23, and  broadcast IP is 172.16.7.255/23




  • For 127th  Subnet, 1st valid IP is 172.16.252.1/23, last valid IP is 172.16.253.254/23, and  broadcast IP is 172.16.253.255/23
  • For 128th  Subnet, 1st valid IP is 172.16.254.1/23, last valid IP is 172.16.255.254/23, and  broadcast IP is 172.16.255.255/23 
 

Subnetting Class B (172.16.0.0/24)

With mask /24, subnet mask will be 255.255.255.0.  Binary value of  3rd  octet is 11111111 and 4th Octet is 00000000. Using this let’s proceed further.
  • Number of subnets (for /24 mask)  =  2N    
             N = 8,  (all 8 bits of 3rd Octet are borrowed for network portion), so 28 = 256
             Number of subnets (for /24 mask) = 256

  • Number of hosts per subnet =  (2H)  - 2     
            H is 8, (all 8 bits of 3rd octet are borrowed as 1 and 8 bits from 4th octet are zero) so  28 - 2. 
            Hosts per subnet = (256 -2) = 254.

  • Block size of each subnet =  256 – 255(decimal value of 3rd octet with all 1s)  = 1

For /24 mask, we will get 256 subnets, each with 254 hosts, each subnet has block size of 1. Below is list of  all 256 subnets:
  • 1st  Subnet  = 172.16.0.0/24
  • 2nd  Subnet = 172.16.1.0/24
  • 3rd  Subnet = 172.16.2.0/24
  • 4th  Subnet = 172.16.3.0/24




  • 255th  Subnet=172.16.254.0/24
  • 256th  Subnet=172.16.255.0/24 

  Below is list of range of IP address of these 256 subnets:
  • For 1st  Subnet, 1st valid IP is 172.16.0.1/24, last valid IP is 172.16.0.254/24, and broadcast IP is 172.16.0.255/24
  • For 2nd  Subnet, 1st valid IP is 172.16.1.1/24, last valid IP is 172.16.1.254/24, and  broadcast IP is 172.16.1.255/24
  • For 3rd  Subnet, 1st valid IP is 172.16.2.1/24, last valid IP is 172.16.2.254/24, and broadcast IP is 172.16.2.255/24
  • For 4th  Subnet, 1st valid IP is 172.16.3.1/24, last valid IP is 172.16.3.254/24, and  broadcast IP is 172.16.3.255/24




  • For 255th  Subnet, 1st valid IP is 172.16.254.1/24, last valid IP is 172.16.254.254/24, and  broadcast IP is 172.16.254.255/24
  • For 256th  Subnet, 1st valid IP is 172.16.255.1/24, last valid IP is 172.16.255.254/24, and  broadcast IP is 172.16.255.255/24


Subnetting Class B (172.16.0.0/26)

With mask /26, subnet mask will be 255.255.255.192.  Binary value of  3rd  octet is 11111111 and 4th Octet is 11000000. Using this let’s proceed further.

  • Number of subnets (for /26 mask)  =  2N    
             N = 10,   (2 bits are borrowed from host portion), so 210  =  1024
             Number of subnets (for /26 mask) = 1024
  • Number of hosts per subnet =  (2H) - 2     
            H is 6, (6 bits of from 4th octet are left zero), so 26 - 2. 
            Hosts per subnet = (64 -2) = 62.


To find Block Size, we need to be careful in calculating the block size because block size for 172.16.0.0/26 will be calculated from 3rd and 4th octets both.
  • Block size from 3rd Octet is 1 and Block size from 4th Octet is 64.  I know you have got confused. But once you look the example below, things will be clearer.
  • Block size of each subnet(3rd Octet) =  256 – 255 =1        (decimal value of 3rd  octet with all 1s). 
  • Block size of each subnet (4th Octet) =  256 – 192  = 64   (decimal value of 4th octet with  two 1s).

For /26 mask, we will get 1024 subnets, each with 62 hosts, each subnet has block size of 64. Below is list of  all 1024 subnets:
  • 1st  Subnet  = 172.16.0.0/26
  • 2nd  Subnet = 172.16.0.64/26
  • 3rd  Subnet = 172.16.0.128/26
  • 4th  Subnet = 172.16.0.192/26
  • 5th   Subnet  = 172.16.1.0/26
  • 6th   Subnet = 172.16.1.64/26
  • 7th   Subnet = 172.16.1.128/26
  • 8th   Subnet = 172.16.1.192/26
  • 9th   Subnet  = 172.16.2.0/26
  • 10th   Subnet = 172.16.2.64/26
  • 11th   Subnet = 172.16.2.128/26
  • 12th  Subnet = 172.16.2.192/26



  • 1021st   Subnet  = 172.16.255.0/26
  • 1022nd   Subnet = 172.16.255.64/26
  • 1023rd   Subnet = 172.16.255.128/26
  • 1024th  Subnet = 172.16.255.192/26

 
Below is list of range of IP address of these 1024 subnets.:

  • For 1st Subnet, 1st valid IP is 172.16.0.1/26, last valid IP is 172.16.0.62/26, and broadcast IP is 172.16.0.63/26
  • For 2nd  Subnet, 1st valid IP is 172.16.0.65/26, last valid IP is 172.16.0.126/26, and  broadcast IP is 172.16.0.127/26
  • For 3rd  Subnet, 1st valid IP is 172.16.0.129/26, last valid IP is 172.16.0.190/26, and broadcast IP is 172.16.0.191/26
  • For 4th  Subnet, 1st valid IP is 172.16.0.193/26, last valid IP is 172.16.0.254/26, and  broadcast IP is 172.16.0.255/26
  • For 5th  Subnet, 1st valid IP is 172.16.1.1/26, last valid IP is 172.16.1.62/26, and broadcast IP is 172.16.1.63/26
  • For 6th   Subnet, 1st valid IP is 172.16.1.65/26, last valid IP is 172.16.1.126/26, and  broadcast IP is 172.16.1.127/26
  • For 7th   Subnet, 1st valid IP is 172.16.1.129/26, last valid IP is 172.16.1.190/26, and broadcast IP is 172.16.1.191/26
  • For 8th   Subnet, 1st valid IP is 172.16.1.193/26, last valid IP is 172.16.1.254/26, and  broadcast IP is 172.16.1.255/26




  • For 1021st   Subnet, 1st valid IP is 172.16.255.0/26, last valid IP is 172.16.255.62/26, and  broadcast IP is 172.16.255.63/26
  • For 1022nd  Subnet, 1st valid IP is 172.16.255.65/26, last valid IP is 172.16.255.126/26, and  broadcast IP is 172.16.255.127/26
  • For 1023rd   Subnet, 1st valid IP is 172.16.255.129/26, last valid IP is 172.16.255.190/26, and  broadcast IP is 172.16.255.191/26
  • For 1024th  Subnet, 1st valid IP is 172.16.255.193/26, last valid IP is 172.16.255.254/26, and  broadcast IP is 172.16.255.255/26
 
I hope you have understood the concept of Class B subnetting. Kindly try the subnetting for 172.16.0.0/28.  Kindly share this article with your friends too.