Search code examples
ip-addresssubnetcidr

Calculate subnet class B address


I am not familiar with the subnet. There is a question.

Organize the IP addresses in a class B address block 158.132.0.0/16 according to the following structures.

Layer1-subnet: Divide the class B address block into 64 subnets of equal size

Layer2-subnet: Take the subnet 0 (i.e., the subnet number is 0) from the 64 subnets and divide it into 4 subnets of equal size.

What is the subnet address using the prefix length notation for the subnet 0 on the (a) Layer1 (b) Layer2

My answer:

a) 158.132.252.0/24

b) 158.132.255.0/26

Both of them are correct?


Solution

  • A subnet is just a further division of any single network you already have. Host addresses can be revealed using masks. CIDR prefixes are primarily used in routing. And class description of addresses is passe, replaced by CIDR where C stands for classless. Here is the overall structure in binary to show subnet allocation.

    158.132.0.0
                            
    10011110 10000100 00000000 00000000
    
       layer 1 subnet   +---------subnets here 6 bits wide or 2^6 or 64
                        V
                      |    | 
    10011110.10000100.000000 00.00000000 <--- 10 bits of host
    
               layer 2 subnet   +---------subnets here 6 bits wide or 2^6 or 64
                                V 
                             |     |   
    10011110.10000100.000000 00.0000 0000 <-- 4 bits of host
            
    

    Given 158.132.0.0/16. That gives 65535 possible addresses on the network including 0 and 65535 for this discussion. 64 is 2^6 so add 6to 16 and you get 22. This would be the CIDR prefix notation for "layer 1" subnets. This allows the high order 6 bits of the third octet in the IP address to house the new subnets.

    64 subnets out of the above would be 158.132.0.0/22. The "layer 1" subnets would then go from

    158.132.0.0/22
    158.132.4.0/22
    158.132.8.0/22
    158.132.12.0/22
    158.132.16.0/22
    ...
    158.132.252.0/22  
    

    Each subnet could handle 2^10 or 1024 hosts.

    Layer 1 subnet zero would be 158.132.0.0/22

    Repeating the process, For 64 more subnets within layer 1 subnet 0, just add 6 to 22 to get 28.

    Layer 2 subnet zero would be 158.132.0.0/28

    And each "layer 2" subnet could handle 16 addresses (again including 0 and 15)

    So what would the layer 2, subnet 3, out of layer 1 subnet 5 be?
    The fifth subnet would be 4 (they start with 0) so the fifth subnet is 16
    Layer 1 subnet 5 is 158.132.16.0/22
    Layer 2 subnet 3 would then be 158.132.16.8/28

    Note: I don't particularly like the terms layer 1 and layer 2 since those are typically used to describe transmission layers in a protocol reference model.