DEV Community

Muhammad Khizr Khan
Muhammad Khizr Khan

Posted on AI-assisted

DevOps from Zero #3: Networking, and how to fix "the site is down"

I'm Muhammad Khizr Khan, a computer science student and full-stack/DevOps developer, learning DevOps in public one class at a time. This is Class 03.

"The site is down" is the most common message in DevOps. Almost every time, the cause is one of a handful of steps between a browser and a server. Today: those steps, and how to check each one.

What happens when you open a website

  1. DNS turns the name into an IP address.
  2. TCP opens a connection to that IP on a port (443 for HTTPS).
  3. TLS checks the certificate and encrypts the line.
  4. HTTP sends the request, and the server sends back a status code and the page.

An outage is almost always one of these steps failing. Your job is to find which one.

IP addresses

Type What it is
Public Reachable from the internet: your server's address
Private 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16: only inside a network
127.0.0.1 Loopback, "this machine" (localhost)
0.0.0.0 When a program listens on it: "every network on this machine"
ip -br addr            # this machine's IPs
curl -s ifconfig.me    # the public IP the internet sees
Enter fullscreen mode Exit fullscreen mode

Ports: the IP is the building, the port is the door

One IP, many services. Each service listens on its own port (0–65535).

Port Service
22 / 80 / 443 SSH / HTTP / HTTPS
5432 / 3306 / 6379 Postgres / MySQL / Redis
sudo ss -tulpn   # list listening ports and the program behind each
Enter fullscreen mode Exit fullscreen mode

DNS: how a name becomes a number

Your computer asks a resolver (your ISP, 1.1.1.1 or 8.8.8.8). The resolver asks the root servers, then the .com servers, then the domain's own (authoritative) DNS, and caches the answer for the record's TTL.

Record Meaning
A / AAAA Name → IPv4 / IPv6
CNAME Name → another name (www → example.com)
MX Which servers receive the domain's email
TXT Text: proof of domain ownership, email security (SPF)
dig +short example.com
dig +short MX example.com
nslookup example.com     # also works on Windows
Enter fullscreen mode Exit fullscreen mode

Tip: /etc/hosts overrides DNS on one machine, which is handy for testing.

TCP vs UDP

  • TCP: connection first (SYN → SYN-ACK → ACK, the "3-way handshake"), delivery checked and in order. Used for the web, SSH and databases.
  • UDP: no connection, no checking, faster. Used for DNS lookups, video calls and games.

HTTP and HTTPS

  • Methods: GET read, POST create, PUT replace, DELETE remove.
  • Status codes:
    • 2xx it worked
    • 3xx go somewhere else
    • 4xx the client asked wrong (404 not found, 403 forbidden)
    • 5xx the server failed (500, 502, 503)
  • HTTPS is HTTP inside TLS. The certificate proves identity and expires (Let's Encrypt: 90 days), so renewal must be automatic.

Subnets (CIDR) in plain English

The number after the slash is how many bits are fixed:

  • /16 = 65,536 addresses
  • /24 = 256 addresses
  • /32 = exactly one

In the cloud, a VPC (say 10.0.0.0/16) is split into a public subnet for web servers and a private subnet for databases.

Firewalls with ufw (without locking yourself out)

sudo ufw default deny incoming
sudo ufw allow 22/tcp        # BEFORE enabling, or you're locked out of SSH
sudo ufw allow 80,443/tcp
sudo ufw enable
sudo ufw status numbered
Enter fullscreen mode Exit fullscreen mode

Open only what you use. Databases should listen on 127.0.0.1 or a private subnet, never on the open internet. On AWS these rules are called Security Groups.

The "site is down" troubleshooting ladder

Climb it from the top. The first step that fails is your problem.

Step Command
1 · DNS dig +short site.com
2 · Reachable ping -c3 IP (some servers block ping)
3 · Path traceroute site.com
4 · Port nc -zv site.com 443
5 · HTTP curl -I https://site.com
6 · Server sudo ss -tulpn, then the app's logs

Install the tools: sudo apt install dnsutils traceroute netcat-openbsd

Next class

Git: never lose your work again.


I'm Muhammad Khizr Khan, a full-stack & DevOps developer and the founder of Axelink Systems. More of my work is on my portfolio, LinkedIn and GitHub. Tried the ladder on a real site? Drop your dig or curl -I output in the comments.

Top comments (1)

Collapse
 
userxnom profile image
Abdullah Naseer •

The ladder is the part beginners actually need — "the site is down" is six different failures wearing one sentence, and climbing DNS, ping, traceroute, nc -zv 443, curl -I, then the logs means the first step that fails is the problem. The ufw warning deserves its own bold line: allow 22/tcp BEFORE enabling, or you lock yourself out of your own server, and I've seen that exact mistake more than once. The /etc/hosts tip is a quiet gem for testing too. Which step on the ladder do you see people skip most often — do they jump straight to the app logs while DNS is still broken?