Understanding Networking Fundamentals: IP Addresses, Subnets, and CIDR

AmulyaAmulya
3 min read

1. IP Addresses: The Foundation

What is an IP Address?

  • An IP address is a unique identifier assigned to devices connected to a network

  • Helps in tracking, monitoring, and controlling access for specific devices

  • Essential for network management and security

IPv4 Address Structure

  • Consists of 4 bytes (32 bits)

  • Each byte is separated by dots (e.g., 192.168.1.1)

  • Each number can range from 0 to 255

  • Format: x.x.x.x where x ∈ [0,255]

Binary Representation

  • Each byte represents 8 bits

  • Maximum value: 11111111 (binary) = 255 (decimal)

  • Example conversion:

    • 192 = 11000000 (binary)

    • Calculation: 2^7 + 2^6 = 128 + 64 = 192

2. Subnetting: Network Segmentation

What is a Subnet?

  • A logical division of a larger network

  • Allows for better organization and security

  • Helps isolate network traffic and control access

Types of Subnets

  1. Private Subnet

    • No direct internet access

    • Used for internal resources

    • Greater security

  2. Public Subnet

    • Has internet access

    • Connected through internet gateway

    • Used for public-facing resources

Benefits of Subnetting

  • Enhanced security through isolation

  • Better network organization

  • Improved network performance

  • Easier network management

3. CIDR (Classless Inter-Domain Routing)

Understanding CIDR Notation

  • Format: IP_Address/prefix_length

  • Example: 172.16.3.0/24

  • Prefix length ranges from 0 to 32

CIDR Calculation

  1. Formula: Available IP addresses = 2^(32 - prefix_length)

  2. Common prefix lengths:

    • /24 = 256 addresses (2^8)

    • /26 = 64 addresses (2^6)

    • /27 = 32 addresses (2^5)

    • /28 = 16 addresses (2^4)

Private IP Address Ranges

  • 10.0.0.0/8 (Class A)

  • 172.16.0.0/12 (Class B)

  • 192.168.0.0/16 (Class C)

4. Network Ports

Understanding Ports

  • Unique numbers assigned to applications on a device

  • Range: 0-65535

  • Format: IP_Address:Port_Number

Common Port Numbers

  • Some ports are reserved for specific services:

    • 80: HTTP

    • 443: HTTPS

    • 3306: MySQL

    • 8080: Often used for development servers

    • Custom applications should use non-standard ports (e.g., 9000, 9191)

Best Practices

  1. IP Address Assignment

    • Use private IP ranges for internal networks

    • Plan subnet sizes based on expected growth

    • Document IP address allocation

  2. Subnet Design

    • Separate sensitive resources into different subnets

    • Use appropriate subnet sizes to avoid waste

    • Consider future scaling needs

  3. Port Usage

    • Avoid using well-known ports for custom applications

    • Document port assignments

    • Consider security implications when opening ports

Practical Example

Creating a VPC with subnets:

  1. Create VPC with CIDR 172.16.0.0/16 (65,536 addresses)

  2. Create finance subnet: 172.16.3.0/24 (256 addresses)

  3. Create general subnet: 172.16.4.0/24 (256 addresses)

This structure provides:

  • Clear network separation

  • Adequate IP addresses for each segment

  • Room for future expansion

2
Subscribe to my newsletter

Read articles from Amulya directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Amulya
Amulya