πŸš€ Networking Basics for Cloud & DevOps Beginners – Part 1 of Docker Networking Series

Harshal SonarHarshal Sonar
5 min read

Before learning Docker Networking, it’s essential to understand basic networking concepts such as IP addresses, subnets, subnet masks, gateways, and CIDR.
Many beginners get confused with these terms, so we will break them down step by step, with examples and visual explanations.

🌐 What is Networking?

Networking is the process of connecting computers, servers, and devices so they can communicate and share data.

Analogy:

  • Your computer β†’ A house

  • IP address β†’ Your house number

  • Network β†’ Your neighborhood

  • Internet β†’ The global city connecting all neighborhoods

Networking allows devices to communicate efficiently and ensures data reaches the correct destination.


πŸ“Œ What is an IP Address?

An IP address (Internet Protocol address) is a unique identifier for a device on a network.

Types of IP addresses

  1. IPv4 – Most common, 4 numbers separated by dots (0–255)

    • Example: 192.168.1.10
  2. IPv6 – Newer version, longer format for more devices

    • Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

🌍 Public vs Private IP

  • Public IP: Visible to the internet (example: 152.57.23.5)

  • Private IP: Used within local networks (example: 192.168.x.x, 10.x.x.x)

πŸ’‘ Docker containers typically get private IPs inside their virtual networks.


🏷 IP Address Classes

ClassRangeDefault Subnet MaskUse Case
A1.0.0.0 – 126.255.255.255255.0.0.0Very large networks
B128.0.0.0 – 191.255.255.255255.255.0.0Medium networks
C192.0.0.0 – 223.255.255.255255.255.255.0Small networks / offices
D224.0.0.0 – 239.255.255.255N/AMulticast
E240.0.0.0 – 255.255.255.255N/AExperimental / Reserved

πŸ“ What is a Subnet?

A subnet splits a network into smaller, manageable parts.

Why subnet?

  • Organize devices efficiently

  • Reduce network congestion

  • Improve security


🧩 What is CIDR (Classless Inter-Domain Routing)?

CIDR is a method to allocate IP addresses and route IP packets more efficiently than the old class-based system (Class A, B, C).

  • CIDR allows flexible subdivision of IP addresses without strictly following class A, B, or C boundaries.

  • Written in IP/prefix length format, e.g., 192.168.1.0/26

    • IP: The network address

    • Prefix length (/26): Number of bits used for the network portion

How CIDR Works

  1. Network bits: Determine the size of the network

  2. Host bits: Determine the number of devices that can be assigned IPs

Example:

  • 192.168.1.0/24 β†’ 24 bits for network, 8 bits for hosts

  • Total addresses = 2^8 = 256 β†’ Usable hosts = 254

  • /24 is the same as default Class C subnet mask 255.255.255.0


CIDR Advantages

  1. Efficient IP allocation – No wastage of IPs, unlike fixed class sizes

  2. Flexible subnetting – Create custom-sized subnets as per requirements

  3. Simplifies routing – Aggregates routes to reduce router memory and routing table size


CIDR Notation Examples

CIDRSubnet MaskTotal IPsUsable IPsNotes
/24255.255.255.0256254Standard Class C
/26255.255.255.1926462Example: 4 subnets from /24
/28255.255.255.2401614Small subnet for few devices
/30255.255.255.25242Point-to-point link

Binary View of CIDR /26:

Subnet mask: 11111111.11111111.11111111.11000000
Network bits: 26 bits
Host bits: 6 bits
Total IPs = 2^6 = 64
Usable IPs = 62

πŸ›  How to Calculate Subnets from an IP Address (Binary Example)

Step 1: Identify Network Class

Example IP: 192.168.1.0 β†’ Class C

  • Default subnet mask: 255.255.255.0 β†’ /24

  • Network bits: first 24 bits

  • Host bits: last 8 bits

Binary view of IP and subnet mask:

IP Address:      192.168.1.0 β†’ 11000000.10101000.00000001.00000000
Subnet Mask:     255.255.255.0 β†’ 11111111.11111111.11111111.00000000
  • Network ID: first 24 bits β†’ 11000000.10101000.00000001 (value = 1 for network ID)

  • Host ID: last 8 bits β†’ 00000000 (value = 0 for host ID)


Step 2: Decide How Many Subnets You Need

Suppose we want 4 subnets for different departments.


Step 3: Calculate How Many Bits to Borrow

  • Number of subnets formula: 2^n = number of subnets

  • 4 subnets β†’ 2^n = 4 β†’ n = 2 bits borrowed

  • Borrow 2 bits from host portion

Binary representation after borrowing 2 bits:

Network ID bits: 11000000.10101000.00000001.00xxxxxx
Host ID bits:    xxxxxx
  • First 2 bits of last octet are now part of the network ID

  • Remaining 6 bits are for host IDs


Step 4: Calculate the New Subnet Mask

  • Original mask: /24 β†’ 255.255.255.0

  • Borrow 2 bits β†’ New mask: /26 β†’ 255.255.255.192

Binary mask:

11111111.11111111.11111111.11000000
  • Last octet binary 11000000 β†’ decimal: 128 + 64 = 192

Step 5: Calculate Subnet Ranges

  • Total addresses per subnet = 2^(host bits) = 2^6 = 64

  • Usable hosts = 64 – 2 = 62

Subnet details (Network ID = 1, Host ID = 0):

SubnetNetwork ID (Binary)Network ID (Decimal)Usable IP Range (Decimal)Broadcast Address (Decimal)
111000000.10101000.00000001.00000000192.168.1.0192.168.1.1 – 192.168.1.62192.168.1.63
211000000.10101000.00000001.01000000192.168.1.64192.168.1.65 – 192.168.1.126192.168.1.127
311000000.10101000.00000001.10000000192.168.1.128192.168.1.129 – 192.168.1.190192.168.1.191
411000000.10101000.00000001.11000000192.168.1.192192.168.1.193 – 192.168.1.254192.168.1.255

Key Points:

  • Network ID: First IP of subnet (cannot assign to host)

  • Host ID: Assignable IPs (usable)

  • Broadcast ID: Last IP, used to send messages to all devices


πŸšͺ Gateway & DNS

  • Gateway: Exit point of the subnet/network; connects local network to internet

  • DNS: Converts domain names to IP addresses (e.g., google.com β†’ 142.250.190.14)


πŸ’‘ Why Beginners Should Learn This

  • Cloud providers (AWS, Azure, GCP) require proper network configuration

  • Docker containers need IPs to communicate

  • Security and troubleshooting depend on understanding networking


βœ… Next Up (Part 2): Docker Networking
Now that you understand networking basics, in Part 2, we will explore Docker Networking β€” how containers get IPs, types of Docker networks, and hands-on commands.

0
Subscribe to my newsletter

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

Written by

Harshal Sonar
Harshal Sonar