IPV4 Addressing and Subnetting

IPV4 Addressing

IPv4 (Internet Protocol version 4) is the fourth version of the Internet Protocol, and it is the most widely used protocol for addressing and routing data on the Internet. IPv4 addresses are 32-bit numerical labels written in dotted-decimal format (e.g., 192.168.0.1). Each IPv4 address is divided into four octets, where each octet is an 8-bit binary number. The basic structure of an IPv4 address looks like this:

A.B.C.D

  • A, B, C, and D are decimal numbers ranging from 0 to 255.
  • Each number in the dotted-decimal format represents an octet in the address.

IPv4 addresses are divided into different classes based on the range of values in the first octet. However, classful addressing is now largely obsolete, and classless addressing (CIDR - Classless Inter-Domain Routing) is commonly used for efficient IP address allocation and routing. CIDR allows for a more flexible allocation of IP addresses.

IPv4 addresses can be categorized into three main types:

  • Unicast Address:
    • Represents a unique address for a single interface on a network. Unicast is used for one-to-one communication.
  • Broadcast Address:
    • Represents all hosts on a particular network. Broadcast communication is sent to all devices on a network.
  • Multicast Address:
    • Represents a group of hosts on a network. Multicast communication is sent to a specific group of devices.

IPv4 also includes special address ranges:

  • Private IP Addresses: Reserved for use within private networks and are not routable over the Internet. Examples include addresses in the ranges 192.168.x.x, 172.16.x.x - 172.31.x.x, and 10.x.x.x.
  • Loopback Address (127.0.0.1): Reserved for testing purposes and allows a device to send network packets to itself.
  • Link-Local Address (169.254.x.x): Automatically assigned to a device when a DHCP (Dynamic Host Configuration Protocol) server is not available.

IPv4 addresses are finite, and with the growth of the Internet, the depletion of available IPv4 addresses became a concern. This led to the development and deployment of IPv6, which uses a 128-bit address space, providing a vastly larger number of unique addresses compared to IPv4.

Subnetting

Subnetting is a technique used in computer networking to divide and allocate an IP network into smaller sub-networks, or subnets. This process is primarily done for the purpose of improving network performance, security, and efficient utilization of IP addresses. Subnetting allows network administrators to create logical and efficient network structures within a larger IP address space.

  • IP Address Classes:
    • IPv4 addresses are traditionally divided into three main classes: A, B, and C. Each class has a default subnet mask:
      • Class A: 1.0.0.0 to 126.0.0.0 (Default Subnet Mask: 255.0.0.0)
      • Class B: 128.0.0.0 to 191.255.0.0 (Default Subnet Mask: 255.255.0.0)
      • Class C: 192.0.0.0 to 223.255.255.0 (Default Subnet Mask: 255.255.255.0)
  • Subnet Mask:
    • The subnet mask is used to divide an IP address into network and host portions. It consists of a series of consecutive 1s followed by a series of consecutive 0s. The network portion of the IP address is determined by the 1s in the subnet mask.
  • Subnetting Process:
    • To subnet an IP network, you borrow bits from the host portion of the IP address to create subnets. This increases the number of available subnets but decreases the number of host addresses within each subnet.
  • Subnetting Notation:
    • Subnetting is often expressed using CIDR notation, which indicates the number of bits used for the network portion of the IP address. For example, a subnet with a CIDR notation of /24 means that the first 24 bits represent the network, and the remaining bits are for host addresses.
  • Subnet Size and Hosts:
    • The size of each subnet is determined by the number of bits borrowed for subnetting. The formula for calculating the number of subnets and hosts in each subnet is 2^n, where "n" is the number of bits borrowed.
      • Number of subnets = 2^n
      • Number of hosts per subnet = 2^(32-n) - 2 (subtracting 2 for network and broadcast addresses)
  • Example:
    • Let's say you have the IP address 192.168.1.0 with a default subnet mask of 255.255.255.0 (/24). If you borrow 3 bits for subnetting, you get a subnet mask of 255.255.255.224 (/27). This creates eight subnets with 32 hosts each.
    • Subnet 1: 192.168.1.0/27 (Hosts: 192.168.1.1 to 192.168.1.30)
    • Subnet 2: 192.168.1.32/27 (Hosts: 192.168.1.33 to 192.168.1.62)
    • ...

Subnetting allows for more efficient use of IP addresses, improves network security by isolating broadcast domains, and helps optimize network performance by reducing broadcast traffic and segmenting larger networks.