Computer Networking - A nexus of nodes
Thinking of sending a letter—you write it, seal it in an envelope, address it, and send it off. The postal service takes care of sorting, transportation, and delivery. Similarly, data traveling across networks follows structured models to ensure smooth communication. That’s where the OSI and TCP/IP models come in—the fundamental blueprints of networking. This blog breaks down these frameworks’ layers, key differences, and real-world significance.
The OSI Model: A 7-Layer Journey
Developed by the International Organization for Standardization (ISO), the Open Systems Interconnection (OSI) model is a theoretical framework dividing network communication into seven layers:
Physical Layer (Layer 1)
Function: Transmits raw bitstreams over physical media (e.g., cables, Wi-Fi).
Devices/Protocols: Hubs, repeaters, Ethernet.
Data Link Layer (Layer 2)
Function: Ensures error-free node-to-node communication using MAC addresses.
Devices/Protocols: Switches, PPP, ARP.
Network Layer (Layer 3)
Function: Routes data between networks via IP addresses.
Devices/Protocols: Routers, IP, ICMP.
Transport Layer (Layer 4)
Function: Manages end-to-end connections and data reliability (TCP) or speed (UDP).
Protocols: TCP, UDP.
Session Layer (Layer 5)
Function: Establishes, maintains, and terminates sessions (e.g., Zoom calls).
Protocols: NetBIOS, RPC.
Presentation Layer (Layer 6)
Function: Translates data into readable formats (encryption, compression).
Protocols: SSL/TLS
Application Layer (Layer 7)
Function: User-facing interfaces for network access.
Protocols: HTTP, FTP, SMTP.
Protocols and Ports for DevOps
CI/CD Pipelines
Jenkins (8080/TCP): Automation server.
GitLab (80, 443, 2222/TCP): Repository & CI/CD.
Containerization & Orchestration
Docker
Docker Daemon (2375/TCP: unencrypted, 2376/TCP: TLS).
Docker Registry (5000/TCP).
Kubernetes
API Server (6443/TCP).
etcd (2379-2380/TCP): Key-value store.
kubelet (10250/TCP).
Monitoring & Logging
Prometheus (9090/TCP): Metrics collection.
Grafana (3000/TCP): Visualization dashboard.
Elasticsearch (9200/TCP): Log storage.
Kibana (5601/TCP): Elasticsearch UI.
Configuration Management
Ansible (SSH/22): Agentless automation.
Chef (443/TCP, 8989/TCP): Infrastructure as code.
Puppet (8140/TCP): System configuration.
AWS EC2 and Security Groups
Steps to launch an Instance
Networking Commands Cheatsheet for DevOps
1. ping
(Check Connectivity)
Purpose: Test reachability and latency to a host.
Usage:
bash
Copy
ping <host/IP>
Common Flags:
-c <count>
: Stop after N packets (Linux/macOS).-t
: Ping until stopped (Windows:ping -t
).-i <seconds>
: Interval between packets (Linux/macOS).
Examples:
bash
Copy
ping google.com # Basic connectivity test
ping -c 4 8.8.8.8 # Send 4 packets (Linux/macOS)
ping -n 4 8.8.8.8 # Windows equivalent
Pro Tip: Use ping
to verify if a host is up or troubleshoot firewall/network issues.
2. traceroute
(Linux/macOS) / tracert
(Windows)
Purpose: Trace the path packets take to reach a host.
Usage:
bash
Copy
traceroute <host/IP> # Linux/macOS
tracert <host/IP> # Windows
Common Flags:
-m <max-hops>
: Limit maximum hops (e.g.,-m 30
).-I
: Use ICMP instead of UDP (Linux).
Example:
bash
Copy
traceroute -m 20 google.com
Pro Tip: Identify network bottlenecks by seeing where latency spikes occur.
3. netstat
(Network Statistics)
Purpose: Display active connections, listening ports, and routing tables.
Usage:
bash
Copy
netstat <flags>
Common Flags:
-a
: Show all connections and listening ports.-t
: TCP connections.-u
: UDP connections.-n
: Show numerical addresses (no DNS resolution).-p
: Show process/PID (Linux:sudo netstat -tunap
).
Examples:
bash
Copy
netstat -tunlp # List all listening TCP/UDP ports (Linux)
netstat -an | grep 3306 # Check if MySQL port is in use
Pro Tip: Use ss
(socket statistics) on modern Linux systems for faster results.
4. curl
(HTTP Requests)
Purpose: Transfer data to/from a server (APIs, downloads, debugging).
Usage:
bash
Copy
curl <URL>
Common Flags:
-X <method>
: Specify HTTP method (GET, POST, etc.).-H "Header: value"
: Add headers.-d "data"
: Send POST data.-o <file>
: Save output to a file.-v
: Verbose mode (show headers).-L
: Follow redirects.
Examples:
bash
Copy
curl -I https://google.com # Fetch headers only
curl -X POST -d '{"key":"value"}' -H "Content-Type: application/json" http://api.example.com
curl -o image.jpg https://example.com/image.jpg
Pro Tip: Use curl
to test APIs, check SSL/TLS handshakes, or debug webhooks.
5. dig
/ nslookup
(DNS Lookup)
Purpose: Query DNS records (A, MX, CNAME, etc.).
Usage:
bash
Copy
dig <domain> # Linux/macOS (more detailed)
nslookup <domain> # Cross-platform (simpler)
Common Flags for dig
:
+short
: Show concise output.-t <type>
: Query specific record type (e.g.,-t mx
).@<dns-server>
: Use a specific DNS server.
Examples:
bash
Copy
dig google.com +short # Get A records
dig -t mx google.com # Query MX records
nslookup example.com 8.8.8.8 # Use Google DNS
Pro Tip: Use dig
for detailed DNS troubleshooting; nslookup
for quick checks.
6. nmap
(Network Mapper)
Purpose: Port scanning and network discovery.
Usage:
nmap <host/IP>
Common Flags:
-p <ports>
: Scan specific ports (e.g.,-p 80,443
).-sS
: Stealth SYN scan.-sV
: Detect service versions.-A
: Aggressive scan (OS, version, script scanning).
Examples:
nmap 192.168.1.1 # Basic scan
nmap -p 1-1000 example.com # Scan ports 1-1000
nmap -sV -O 10.0.0.5 # Detect OS and services
Pro Tip: Always get permission before scanning external networks.
7. ss
(Socket Statistics)
Purpose: Modern replacement for netstat
(Linux).
Usage:
ss <flags>
Common Flags:
-t
: TCP sockets.-u
: UDP sockets.-l
: Listening sockets.-n
: Show numerical addresses.
Example:
ss -tulnp # Show all listening TCP/UDP ports with processes
8. telnet
Purpose: Test TCP port connectivity (not encrypted!).
Usage:
telnet <host> <port>
Example:
telnet example.com 80 # Check if port 80 is open
9. tcpdump
Purpose: Capture and analyze network traffic.
Usage:
tcpdump -i <interface> <filters>