More

    Important concepts related to IP addresses and CIDR

    Let us first quickly go through some important concepts related to IP addresses and CIDR:

    • An IPv4 address has 32 bits divided into 4 octets (Each octet consist of 8 bits). Each part (octet of bits) is represented in their decimal form separated by dots. E.g. 10.12.14.16. This format is referred to as dotted decimal format.
    • The maximum decimal number that any of the four parts of an IPv4 address can hold is 255 as the largest binary number that can be represented by 8 bits is 11111111.
    • Bits of an IP address can be divided into two parts:
      • First part (most significant bits) is used to identify the networks and is generally referred to as Network Identifier (NID) bits.
      • The second part (least significant bits) is used to represent the hosts within those networks and is generally referred to as Host Identifier (HID) bits.
    • For an IPv4 address, the total number of bits is 32. Therefore, if the NID has 24 bits, then the HID will have 8 bits. For an IPv6 address, the total number of bits is 128.
    • We can calculate the number of IP addresses possible within a network from the number of HID bits. For example, if the number of HID bits is 8, then we can have 256 different IP addresses (calculated as 2 to the power 8).
    • In general, we cannot use two IP address from our IP address range, as the first one represent the network’s id and the last one represent the directed broadcast IP address. AWS has specified some additional restrictions to this.
    • Sending message to multiple hosts is called broadcasting. Broadcasting can be of two types:
      • Limited broadcasting refers to sending message to all hosts on the same network using the IP address 255.255.255.255.
      • Directed broadcasting refers to sending messages to all hosts in another network using the directed broadcast IP address of the other network. The directed broadcast IP address is the last IP address within a network (or subnets if they are available).
    • Sending a message to a specific host’s IP address is called unicasting.
    • CIDR stands for Classless Inter-Domain Routing and is a scheme used for allocating IP addresses and IP routing.
    • In the CIDR block address format, we represent a block (IP address range) in the form a.b.c.d/n where a.b.c.d represent an IP address within that block and n is the netmask size.
    • Netmask is a value that is used by routers to calculate the network identifier for a network from an IP address. It consists of leading 1’s corresponding to NID bits and 0’s corresponding to HID bits. If we do an AND operation of any IP address with its netmask, we will get the NID for that network. Consider a CIDR block address of 10.0.0.32/24. The IP address 10.0.0.32 can be represented in Binary as follows: 00001010.00000000.00000000.00000000.00100000. Network mask for this block would be 11111111.11111111.11111111.00000000. If we do an AND operation on both binary representations, we will get 00001010.00000000.00000000.00000000.00000000, which can be represented in dotted decimal format as 10.0.0.0. This is the network identifier for our block and is also the first IP within our block.
    • In theory, we can specify any IP address within a CIDR block in the CIDR block format. However, AWS requires us to leave all HID bits as zero, specifying only the NID bits according to the netmask value.
    • A netmask value within a CIDR block representation corresponds to the number of NID bits for our block. A netmask also includes bits for identifying subnets.
    • Netmask can be used to calculate the HID bits and hence the number of possible hosts. Consider an IPv4 CIDR address range 10.11.12.32/27. Here, netmask is /27, so the first 27 bits represent NID and rest 5 bits represent HID. The IP address parts represented by 10, 11 and 12 constitute 24 bits. 3 more bits from the last part is also part of the NID. The last part has a decimal value of 32, which can be represented in Binary octet as 00100000. First three bits 001 is part of NID and the remaining five bits 00000 represent the HID.
    • Before CIDR, we had class-based classifications where each class of IP address range had predefined sizes for network and host bits. Following are the predefined NID and HID sizes for various classes in a class-based classification:
      • Class A – NID has 8 bits, HID has 24 bits. It has a fixed prefix of 0 and hence the number of available NIDs is 2 power 7 ranging from 0 to 127. Number of available HIDs is 2 power 8.
      • Class B – NID has 16 bits, HID has 16 bits. It has a fixed prefix of 10 and hence the number of available NIDs is 2 power 14 ranging from 128.0 to 191.255. Number of available HIDs is 2 power 16.
      • Class C – NID has 24 bits, HID has 8 bits. It has a prefix of 110 and hence the number of available NIDs is 2 power 21 ranging from 192.0.0 to 223.255.255. Number of available HIDs is 2 power 24.
      • Class D and Class E does not have NID and HID separation. While Class D is reserved for multicasting, Class E is reserved for future use.
    • With the class-based classification, we had less flexibility in choosing the IP address ranges as per our need and hence CIDR was introduced.

    Recent Articles

    OAUTH – FREQUENTLY ASKED QUESTIONS FOR INTERVIEWS AND SELF EVALUATION

    Why is refresh token needed when you have access token? Access tokens are usually short-lived and refresh tokens are...

    SUMO LOGIC VIDEOS AND TUTORIALS

    Sumo Logic Basics - Part 1 of 2 (link is external) (Sep 29, 2016)Sumo Logic Basics - Part 2 of 2...

    GIT – USEFUL COMMANDS

    Discard all local changes, but save them for possible re-use later:  git stash Discarding local changes...

    DISTRIBUTED COMPUTING – RECORDED LECTURES (BITS)

    Module 1 - INTRODUCTION Recorded Lecture - 1.1 Introduction Part I – Definition

    BOOK REVIEW GUIDELINES FOR COOKBOOKS

    Whenever you add reviews for the book, please follow below rules. Write issues in an excel.Create an excel...

    Related Stories

    Leave A Reply

    Please enter your comment!
    Please enter your name here

    Stay on op - Ge the daily news in your inbox