π Networking Basics for Cloud & DevOps Beginners β Part 1 of Docker Networking Series

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
IPv4 β Most common, 4 numbers separated by dots (0β255)
- Example:
192.168.1.10
- Example:
IPv6 β Newer version, longer format for more devices
- Example:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
- Example:
π 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
Class | Range | Default Subnet Mask | Use Case |
A | 1.0.0.0 β 126.255.255.255 | 255.0.0.0 | Very large networks |
B | 128.0.0.0 β 191.255.255.255 | 255.255.0.0 | Medium networks |
C | 192.0.0.0 β 223.255.255.255 | 255.255.255.0 | Small networks / offices |
D | 224.0.0.0 β 239.255.255.255 | N/A | Multicast |
E | 240.0.0.0 β 255.255.255.255 | N/A | Experimental / 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
Network bits: Determine the size of the network
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 hostsTotal addresses =
2^8 = 256
β Usable hosts = 254/24
is the same as default Class C subnet mask255.255.255.0
CIDR Advantages
Efficient IP allocation β No wastage of IPs, unlike fixed class sizes
Flexible subnetting β Create custom-sized subnets as per requirements
Simplifies routing β Aggregates routes to reduce router memory and routing table size
CIDR Notation Examples
CIDR | Subnet Mask | Total IPs | Usable IPs | Notes |
/24 | 255.255.255.0 | 256 | 254 | Standard Class C |
/26 | 255.255.255.192 | 64 | 62 | Example: 4 subnets from /24 |
/28 | 255.255.255.240 | 16 | 14 | Small subnet for few devices |
/30 | 255.255.255.252 | 4 | 2 | Point-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 borrowedBorrow 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):
Subnet | Network ID (Binary) | Network ID (Decimal) | Usable IP Range (Decimal) | Broadcast Address (Decimal) |
1 | 11000000.10101000.00000001.00000000 | 192.168.1.0 | 192.168.1.1 β 192.168.1.62 | 192.168.1.63 |
2 | 11000000.10101000.00000001.01000000 | 192.168.1.64 | 192.168.1.65 β 192.168.1.126 | 192.168.1.127 |
3 | 11000000.10101000.00000001.10000000 | 192.168.1.128 | 192.168.1.129 β 192.168.1.190 | 192.168.1.191 |
4 | 11000000.10101000.00000001.11000000 | 192.168.1.192 | 192.168.1.193 β 192.168.1.254 | 192.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.
Subscribe to my newsletter
Read articles from Harshal Sonar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
