Networking Funda for devops

๐ IP Address
An IP address (Internet Protocol address) is a unique numerical identifier assigned to each device on a network that uses the Internet Protocol.
It has used for identifying the host or network interface
๐ฆ Types of IP Addresses
๐ข By IP Protocol Version
IPv4 (๐ 32-bit):
192.168.1.1
- ~4.3 billion addresses, exhaustion-prone, still widely used.
IPv6 (๐งฎ 128-bit):
2001:db8:abcd::1
- ~3.4ร10ยณโธ addresses, designed to replace IPv4.
๐ By Accessibility
Public IP ๐: Routable on the Internet, assigned by ISPs or cloud providers (e.g., AWS Elastic IP)
Private IP ๐ : Used inside internal networks (LANs)
Reserved ranges:
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
โ๏ธ By Assignment
Static IP ๐: Manually configured, persistent (e.g., production servers, DNS records)
Dynamic IP ๐: Assigned by DHCP, changes over time (clients, cloud VMs)
๐งฎ IPv4 Address Format
Written in dotted decimal notation:
A.B.C.D
Each segment (
A
,B
,C
,D
) is 8 bits (1 byte) โ Total: 4 bytes = 32 bitsExample:
192.168.10.25
- Binary:
11000000.10101000.00001010.00011001
- Binary:
๐ Subnets
Subnetting is the process of dividing a larger IP network into multiple smaller subnetworks (subnets). Each subnet is treated as an isolated logical segment within the larger infrastructure.
Besides efficient IP allocation , a critical benefit of subnetting is enhanced security.
๐ก๏ธ Why Subnetting Improves Security
By splitting a network into subnets:
Devices in one subnet cannot directly access devices in another subnet unless explicitly allowed through firewalls, routing rules, or gateways.
It limits the blast radius of attacks โ a compromise in one subnet doesnโt expose the entire network.
It allows DevOps and NetSec teams to apply granular access control policies between environments or layers.
๐ ๏ธ Practical DevOps Example: Secure Subnet Design in AWS
Letโs say you're building a cloud architecture with the following components:
๐ฉ Web servers (public-facing)
๐จ App servers (internal processing logic)
๐ฅ Database servers (critical, highly secured)
Instead of deploying all resources in one subnet, you create separate subnets:
Subnet Name | CIDR Block | Exposure | Purpose |
public-subnet | 10.0.0.0/24 | Public (via IGW) | Hosts NGINX web servers |
app-subnet | 10.0.1.0/24 | Private | Internal app services |
db-subnet | 10.0.2.0/24 | Private | RDS or PostgreSQL DB |
Security enforcement using subnet isolation:
๐ Web servers in the public subnet only have access to the app subnet on port 8080 (custom app port).
๐ App servers can access the DB subnet on port 5432 (PostgreSQL), but web servers cannot.
๐ซ The DB subnet has no internet access and is restricted to app servers only.
This subnetting model:
Prevents direct attacks on the database from the internet
Ensures each layer of the stack is logically separated
Enables network ACLs and security groups to enforce least privilege
๐ CIDR (Classless Inter-Domain Routing)
CIDR (Classless Inter-Domain Routing) is a method of allocating IP addresses and routing IP packets more efficiently than the old class-based system (Class A, B, C). Introduced in 1993 via RFC 1519, CIDR allows flexible subnetting and address aggregation.
๐งฎ Syntax:
<IP address>/<prefix length>
Example: 192.168.1.0/24
IP address: network identifier
Prefix length: number of bits that represent the network portion of the address
๐ ๏ธ Practical Use Cases in DevOps
๐ฆ 1. Cloud Network Design (e.g., AWS, Azure, GCP)
You create a VPC with CIDR
10.0.0.0/16
(Allows 65,536 IPs)You divide it into subnets:
10.0.0.0/24
โ public subnet (web)10.0.1.0/24
โ private subnet (app)10.0.2.0/24
โ isolated subnet (db)
โ๏ธ 2. Firewall and Routing Rules
You restrict inbound traffic to a specific subnet:
192.168.1.0/24
You allow SSH access only from your office IP:
203.0.113.55/32
CIDR lets you define precise IP ranges in:
๐ Security groups
๐ NACLs
๐ Route tables
๐ช Load balancer listener rules
๐ณ 3. Docker Custom Bridge Networks
Docker default bridge is
/16
, but you can create:docker network create \ --subnet=172.18.0.0/16 \ custom-net
You can then manually assign static container IPs in that range.
๐งช 4. Subnet Scanning and Troubleshooting
Tools like
nmap
,masscan
,tcpdump
often take CIDR:map -sP 10.0.1.0/24 tcpdump net 192.168.0.0/16
๐งฐ 5. Kubernetes Cluster Networking
Pod networks often use CIDR blocks:
e.g.,
10.244.0.0/16
for FlannelCNI plugins require non-overlapping CIDRs for pods and services
๐งช CIDR Conversion Example (IP + Required no of Hosts โ CIDR)
๐ฏ Problem Statement
You are deploying a microservice cluster and need:
Minimum 50 usable IP addresses
Your base network IP is:
192.168.100.0
You need to determine: What CIDR block to use?
โ Step-by-Step Solution
๐งฎ Step 1: Calculate Total Required IPs
You need 50 usable IPs
But 2 IPs are reserved in every subnet:
Network Address
Broadcast Address
๐ Formula: Required = Hosts + 2 = 50 + 2 = 52
๐ง Step 2: Find the Smallest Power of 2 โฅ 52 => 2^6 = 64 โ
So you need 64 total IPs in this subnet.
๐ Step 3: Calculate CIDR Prefix
IPv4 has 32 bits total.
If 2โถ = 64 addresses, then 6 bits are for hosts โ
๐ง Network bits = 32 - 6 = 26
โ Final CIDR Block: 192.168.100.0/26
๐ Ports
A port is a 16-bit number used to identify specific processes/services on a device in a network.
While an IP address identifies a host, a port number identifies an application or service running on that host.
Total possible ports: 0 โ 65535
Ports operate over TCP and UDP transport protocols
๐ Port Ranges
Range | Type | Example Use |
0 โ 1023 | Well-known ports | HTTP (80 ), HTTPS (443 ), SSH (22 ), DNS (53 ) |
1024 โ 49151 | Registered ports | Custom apps, databases (e.g., PostgreSQL 5432 ) |
49152 โ 65535 | Dynamic/Ephemeral | Client-side ports, auto-assigned |
๐ ๏ธ Relevance
๐ Configure firewalls, Security Groups, or NACLs to allow/deny traffic on specific ports
๐ณ Expose and map container ports using Docker:
docker run -p 8080:80 nginx
โ๏ธ Load balancers and proxies listen on front-end ports and forward to back-end ports
๐ What is the OSI Model?
The OSI (Open Systems Interconnection) Model breaks down network communication into 7 abstract layers, each with specific responsibilities, enabling interoperability, modularity, and troubleshooting.
๐งญ The 7 Layers of OSI โ Top to Bottom
Layer | Name | Function Summary | Protocols/Tools (Examples) |
7๏ธโฃ | Application | User interface, application services, headers | HTTP, HTTPS, DNS, FTP, SSH |
6๏ธโฃ | Presentation | Data format, encryption, compression | SSL/TLS, JPEG, ASCII, JSON, XML |
5๏ธโฃ | Session | Session setup, management, teardown | RPC, NetBIOS, NFS, SMB |
4๏ธโฃ | Transport | Reliable delivery, flow control | TCP, UDP, QUIC |
3๏ธโฃ | Network | Routing, logical addressing | IP, ICMP, IGMP, BGP, OSPF |
2๏ธโฃ | Data Link | MAC addressing, frame transfer | Ethernet, PPP, VLAN, ARP |
1๏ธโฃ | Physical | Raw bits over physical medium | Cables, Hubs, NICs, Wi-Fi, Fiber |
๐ฆ Layer-by-Layer Breakdown with DevOps Relevance
๐น Layer 1 โ Physical Layer
Deals with hardware-level transmission: voltages, cables, radio signals
Converts binary data (0s and 1s) into electrical, optical, or radio signals
๐ธ Layer 2 โ Data Link Layer
Provides node-to-node delivery within the same local network
Uses MAC addresses for device identification
Handles framing, error detection (CRC), and flow control
๐น Layer 3 โ Network Layer
Provides end-to-end routing across networks
Uses IP addressing, determines best path to destination
Handles fragmentation and reassembly
๐ธ Layer 4 โ Transport Layer
Manages reliable or unreliable delivery of data
Handles segmentation, retransmission, flow control, and port addressing
Two main protocols:
TCP (reliable, connection-oriented)
UDP (fast, connectionless)
๐น Layer 5 โ Session Layer
Controls establishing, managing, and terminating sessions
Supports authentication, reconnection, and checkpointing
๐ธ Layer 6 โ Presentation Layer
Responsible for data format translation, encryption, compression
Converts data into formats usable by the application layer
๐น Layer 7 โ Application Layer
Closest to the end user
Interfaces directly with software to send and receive data
Includes high-level protocols and services
๐ง OSI vs TCP/IP (Quick Note)
While OSI has 7 layers, the TCP/IP model (used practically) has 4:
Application (OSI 5-7)
Transport (OSI 4)
Internet (OSI 3)
Link (OSI 1-2)
โ Summary Table
Layer | Name | Keywords |
7 | Application | APIs, HTTP, DNS |
6 | Presentation | Encryption, JSON, TLS |
5 | Session | Sessions, state |
4 | Transport | TCP/UDP, ports |
3 | Network | IP, routing |
2 | Data Link | MAC, Ethernet |
1 | Physical | Cables, Wi-Fi |
Subscribe to my newsletter
Read articles from Rajesh Gurajala directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
