📡

Understanding Classless Subnetting and CIDR

Oct 27, 2024

Classless Subnetting and CIDR

Transition from Class-based to Classless Subnetting

  • Pre-1993: IP addresses had class-based subnetting (Class A, B, C).
  • Post-1993: Shift to classless subnetting, known as Classless Inter-Domain Routing (CIDR).
  • CIDR allows subnet masks that do not conform to Class A, B, or C.

CIDR Block Notation

  • Subnet masks are expressed in terms of bits, not decimals.
  • CIDR block notation: e.g., /24 means 24 bits are part of the subnet mask.
  • Example: IP 192.168.1.44/24 refers to 24 bits in the subnet mask.

Configuration Practices

  • Different devices may require different notations for subnet masks (decimal vs. CIDR block).
    • Operating Systems: Often use decimal notation.
    • Routers/Switches: May use CIDR block notation.
  • Always check device documentation for preferred subnet mask format.

Structure of a Subnet Mask

  • Subnet masks are a series of contiguous 1s followed by 0s.
    • Example: Three octets of 1s (24 1s) means a /24 CIDR notation.
    • Purpose: Separates the network part from the host part of the address.

Converting Binary to CIDR Block

  • Count the number of 1s to determine the CIDR notation.
    • Example: Two octets of 1s (16 1s) = /16.
    • Example: Three octets of 1s and two 1s in fourth octet (26 1s) = /26.
  • Slash notation indicates network bits vs. host bits.

Conversion to Decimal

  • Binary 1s and 0s convert into decimals for easier understanding.
    • Single 1 = 128, Two 1s = 192, Three 1s = 224, etc.
  • Create a chart for binary-to-decimal conversion of subnet masks.
    • Example: /12 corresponds to 255.240.0.0 in decimal.

Examples of CIDR and Decimal Conversion

  • Example 1: All 1s in first octet, four 1s in second octet: /12.
    • Decimal: 255.240.0.0
  • Example 2: All 1s in first and second octet, three 1s in third octet: /19.
    • Decimal: 255.255.224.0
  • Reverse Conversion: Given /26, binary is three full octets of 1s and two 1s in the last octet.
    • Decimal: 255.255.255.192

Practical Applications

  • Use CIDR for determining network and host sections of addresses efficiently.
  • Convert between CIDR and decimal as needed for configuration and understanding.