🌐 Networking
Networking & DevOps
TCP/IP, DNS, HTTP, Docker, CI/CD, and cloud fundamentals — your infrastructure quick reference.
01TCP/IP & OSI Model▼
| Layer | Name | Protocol/Example |
|---|---|---|
| 7 | Application | HTTP, HTTPS, FTP, SMTP, DNS |
| 6 | Presentation | SSL/TLS, encoding |
| 5 | Session | Sockets, NetBIOS |
| 4 | Transport | TCP (reliable), UDP (fast) |
| 3 | Network | IP, ICMP, routing |
| 2 | Data Link | Ethernet, MAC addresses |
| 1 | Physical | Cables, Wi-Fi, bits |
TCP
Connection-oriented. 3-way handshake: SYN, SYN-ACK, ACK. Reliable, ordered delivery.
UDP
Connectionless. No handshake. Fast, no guarantee. Video streaming, DNS, gaming.
IP Address
IPv4: 32-bit (192.168.1.1). IPv6: 128-bit.
Subnet mask
255.255.255.0 = /24. First 24 bits = network, last 8 = hosts.
NETCommon ports
80 = HTTP 443 = HTTPS 22 = SSH 21 = FTP 25 = SMTP 3306 = MySQL 5432 = PostgreSQL 27017= MongoDB 6379 = Redis 3000 = Node.js dev 8080 = Alt HTTP
02DNS & HTTP▼
DNS resolution
Domain -> Recursive resolver -> Root NS -> TLD NS -> Authoritative NS -> IP
DNS records
A: domain to IPv4. AAAA: IPv6. CNAME: alias. MX: mail. TXT: verification.
TTL
Time to Live. How long DNS is cached. Lower = faster propagation.
HTTP methods
GET: fetch, POST: create, PUT: replace, PATCH: update, DELETE: remove
Status codes
2xx: success, 3xx: redirect, 4xx: client error, 5xx: server error.
HTTPS
HTTP + TLS encryption. Certificate from CA. Let's Encrypt = free.
| Status | Meaning |
|---|---|
| 200 | OK |
| 201 | Created |
| 301 | Moved Permanently |
| 302 | Found (temp redirect) |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 422 | Unprocessable Entity |
| 429 | Too Many Requests |
| 500 | Internal Server Error |
| 502 | Bad Gateway |
| 503 | Service Unavailable |
03Docker▼
DOCKERDocker essentials
# Images docker pull node:18 # download image docker images # list images docker rmi image_id # remove image docker build -t myapp . # build from Dockerfile # Containers docker run -p 3000:3000 myapp # run container docker run -d -p 3000:3000 myapp # detached mode docker run -e PORT=3000 myapp # env variable docker ps # running containers docker ps -a # all containers docker stop container_id docker rm container_id docker exec -it container_id bash # shell into container # Volumes (persist data) docker run -v /host/path:/container/path myapp # Logs docker logs container_id docker logs -f container_id # follow
DOCKERDockerfile
FROM node:18-alpine WORKDIR /app COPY package*.json ./ RUN npm install --production COPY . . EXPOSE 3000 CMD ["node", "server.js"]
04Docker Compose & CI/CD▼
DOCKERdocker-compose.yml
version: "3.8"
services:
app:
build: .
ports:
- "3000:3000"
environment:
- MONGO_URI=mongodb://mongo:27017/mydb
depends_on:
- mongo
volumes:
- .:/app
mongo:
image: mongo:6
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db
volumes:
mongo_data:
# Commands:
# docker-compose up -d start all
# docker-compose down stop all
# docker-compose logs -f follow logsCICDGitHub Actions
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with: { node-version: 18 }
- run: npm install
- run: npm test
- name: Deploy
run: echo "Deploy step here"❓ Quiz
What does docker run -d -p 3000:3000 do?
-d = detached (background). -p 3000:3000 = hostPort:containerPort mapping. Without -d, it runs in foreground and blocks your terminal.
05Cloud & AWS Basics▼
| AWS Service | What it does | Free tier |
|---|---|---|
| EC2 | Virtual servers (Linux/Windows) | 750 hrs/mo t2.micro |
| S3 | Object storage (files, images) | 5GB storage |
| Lambda | Serverless functions | 1M requests/mo |
| RDS | Managed SQL database | 750 hrs db.t2.micro |
| CloudFront | CDN for fast content delivery | 1TB transfer/mo |
| Route 53 | DNS management | $0.50/zone/mo |
| IAM | Access control and users | Always free |
| ElastiCache | Redis/Memcached managed | No free tier |
Regions & AZs
Regions are geographic areas. Availability Zones are isolated data centers within a region.
Security groups
Virtual firewall. Control inbound/outbound traffic by port and IP.
IAM best practices
Least privilege principle. Never use root account. Use roles for services.
06Nginx & Reverse Proxy▼
NGINXNginx config for Node.js
# /etc/nginx/sites-available/mysite
server {
listen 80;
server_name yourdomain.com;
# Redirect HTTP to HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
# Serve frontend static files
location / {
root /var/www/html;
try_files $uri $uri/ /index.html;
}
# Proxy API to Node.js
location /api/ {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
# Commands:
# nginx -t test config
# systemctl reload nginx