Networking Funda for devops

Rajesh GurajalaRajesh Gurajala
8 min read

๐ŸŒ 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 bits

  • Example: 192.168.10.25

    • Binary: 11000000.10101000.00001010.00011001

๐Ÿ” 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 NameCIDR BlockExposurePurpose
public-subnet10.0.0.0/24Public (via IGW)Hosts NGINX web servers
app-subnet10.0.1.0/24PrivateInternal app services
db-subnet10.0.2.0/24PrivateRDS 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 Flannel

    • CNI 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

RangeTypeExample Use
0 โ€“ 1023Well-known portsHTTP (80), HTTPS (443), SSH (22), DNS (53)
1024 โ€“ 49151Registered portsCustom apps, databases (e.g., PostgreSQL 5432)
49152 โ€“ 65535Dynamic/EphemeralClient-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

LayerNameFunction SummaryProtocols/Tools (Examples)
7๏ธโƒฃApplicationUser interface, application services, headersHTTP, HTTPS, DNS, FTP, SSH
6๏ธโƒฃPresentationData format, encryption, compressionSSL/TLS, JPEG, ASCII, JSON, XML
5๏ธโƒฃSessionSession setup, management, teardownRPC, NetBIOS, NFS, SMB
4๏ธโƒฃTransportReliable delivery, flow controlTCP, UDP, QUIC
3๏ธโƒฃNetworkRouting, logical addressingIP, ICMP, IGMP, BGP, OSPF
2๏ธโƒฃData LinkMAC addressing, frame transferEthernet, PPP, VLAN, ARP
1๏ธโƒฃPhysicalRaw bits over physical mediumCables, 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

  • 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

LayerNameKeywords
7ApplicationAPIs, HTTP, DNS
6PresentationEncryption, JSON, TLS
5SessionSessions, state
4TransportTCP/UDP, ports
3NetworkIP, routing
2Data LinkMAC, Ethernet
1PhysicalCables, Wi-Fi
10
Subscribe to my newsletter

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

Written by

Rajesh Gurajala
Rajesh Gurajala