Mega Menu

Friday, May 08, 2020

Networks - IP Address Range Computation

How to determine the number of IP addresses available for a given subnet range?
   
Quite common query most of us has and will try to explain a bit on how this can be evaluated.

        Each IP address is a represent as 32 bits, each set of 8 bits separated by a dot (.)

        10.0.0.1 stands for
                        0000 1010.0000 0000.0000 0000.0000 0001

                            Bits are computed by adding values of positions
       POSITIONS       8       7     6      5      4     3      2      1     
       Value                2^7   2^6  2^5  2^4  2^3  2^2  2^1  2^0   i.e.
  Computed Value   128   64    32   16    8      4     2      1
                   
                10 can be formed only when positions 4 and 2 have a value i.e. 0000 1010
                 Few Examples
                        0 = 0000 0000      (0)
                        1 = 0000 0001      (1)
                        2 = 0000 0010      (2)
                        3 = 0000 0011      (2 + 1)
                      40 = 0010 1000      (32 + 8)
                    255 = 1111 1111       (128+64+32+16+8+4+2+1)

 Subnet Range
        Eg: 10.0.0.0/16    (16 is the CIDR Range - Classless Inter-domain Routing)
                This subnet range indicates that, of all the 32 bits of an IP, the last 16 (32-16) bits can be used to define the Host Names, while the first 16 bits are Network Identifiers.

            The range of ips for this subnet would be
                        10.0.(0-255).(0-255) which would be about 2^16 i.e. 65536 IPs.

        Similarly, 10.0.0.0/24 means, the last 8 (32 - 24) bits can be changed to form host names i.e.
                        10.0.0.(0-255), which would be about 2^8 Ips i.e. 256 IPs

                        10.0.0.0/28 means, the last 4 (32 - 28) bits can be changed to form host names i.e.
                        10.0.0.(0-15), which would be about 2^4 Ips i.e. 16 IPs

            An alternate way to calculate the IP count --
                    For a subnet 10.0.1.0/24
                        Total bits = 32
                        Usable = 32 - 24 = 8 (24 is the CIDR range)
                        Total IPs = 2^8 (8 is the usable bit count) = 256

                Example 2: For subnet 10.0.1.0/30
                        Total bits = 32
                        Usable = 32 - 30 = 2 (30 is the CIDR range)
                        Total IPs = 2^2 (2 is the usable bit count) = 4
                                    i.e. 10.0.1.0, 10.0.1.1, 10.0.1.2, 10.0.1.3


        Hope this helps !!!


                        

No comments:

Post a Comment