Search code examples
ip-addresssubnet

Calculating Network Addresses


The question is as follows.

Consider a router that interconnects three subnets: A, B, and C. Suppose all of the interfaces in each of these subnets are required to have the prefix 119.61.96.0/19. Suppose subnet A and B are each required to support 2000 interfaces, and subnet C is required to support 4000 interfaces. Provide network addresses for A,B and C (in the form a.b.c.d/x) that satisfy these constraints.

I have the answer for A as 119.61.112.0/21.

I believe that is acceptable. I understand the /21 part somewhat, 2^11 so take that from 32bits thats where the /21 comes from. Something along that logic. What confuses me why is 112 acceptable. I have tried converting the whole thing to binary and still can't see why. I know you must do something with 2^11, like this ? 0/000 0000 0000

Anyways, If someone could point me in the correct way, If I understand the first one I should be able figure out the rest. If I am way off, I do apologize.

I appreciate it, Thanks.


Solution

  • An IPv4 is 4 bytes (32 bits). Each byte can take a value from 0 to 255.

    119.61.96.0/19 is saying that the highest 19 bits will be allways the same:

    The binary representation (higher bits on the left):

    01110111.00111101.01100000.00000000 
    

    The first 19 bits:

    01110111.00111101.011
    

    Subnets A and B need 2000 addresses, the nearest power of 2 is 11 (2048). This means they need adresses of 11 bits.

    Subnet C needs 4000 addresses, the nearest power of 2 is 12 (4096). This means they need address of 12 bits.

    For the C subnet:

    32 bits of IPv4 address 
    - 19 bits (fixed) 
    - 12 bits (address space) 
    -------------------------
    = 1 bits we can use to divide in subnets of 4096 addresses
    

    If (conveniently for the OP) we select the 20th bit with value 0 as the C subnet, C would be defined as:

    01110111.00111101.0110 = 119.61.96.0/20
    

    For A nd B subnets

    32 bits of IPv4 address 
    - 19 bits (fixed) 
    - 11 bits (address space) 
    -------------------------
    = 2 bits we can use to divide in subnets of 2048 addresses
    

    As C subnet has the 20th bit set to 0 for A and B this bit will have a value of 1. And the 21st bit (again conveniently for the OP) we will define the value of 0 for subnet A and 1 for subnet B.

    Subnet A

    01110111.00111101.01110 = 119.61.112.0/21
    

    Subnet B

    01110111.00111101.01111 = 119.61.120.0/21