Networking Essentials
DNS, TCP/IP, HTTP, ports, and the networking knowledge DevOps engineers need.
IP addresses and ports
Every machine on a network has an IP address. Every service on a machine listens on a port. Together, IP:port uniquely identifies a service.
bash
# See your IP addresses
$ ip addr show
$ hostname -I
# See what is listening on ports
$ ss -tlnp # modern
$ netstat -tlnp # older systems
$ lsof -i :80 # what is on port 80
# Common ports
# 22 SSH
# 80 HTTP
# 443 HTTPS
# 5432 PostgreSQL
# 6379 Redis
DNS
DNS translates domain names like thelastdeploy.com to IP addresses. Every network request starts with a DNS lookup.
bash
# Look up a domain
$ nslookup thelastdeploy.com
$ dig thelastdeploy.com
# Local DNS config
$ cat /etc/resolv.conf # DNS servers
$ cat /etc/hosts # Local overrides
HTTP
HTTP is the protocol that powers the web. Every request has a method, headers, and optionally a body. Every response has a status code.
| Status code | Meaning |
|---|---|
| 200 OK | Success |
| 201 Created | Resource created |
| 301/302 | Redirect |
| 400 Bad Request | Client error — bad input |
| 401 Unauthorized | Auth required |
| 403 Forbidden | Auth succeeded but no permission |
| 404 Not Found | Resource does not exist |
| 500 Internal Server Error | Server-side bug |
| 502 Bad Gateway | Upstream service failed |
| 503 Service Unavailable | Service overloaded or down |
