Loading
0xC0Lesson 13 of 14

Diagnose a broken network

Work up the layers with real tools to find a root cause.

30 min 7-question quiz 2 code exercises
By the end of this lesson you can
  • Troubleshoot methodically, from the bottom of the stack up.
  • Read the output of ping, dig, curl and related tools.
  • Tell a DNS problem from a connectivity or application problem.

“The Internet is down” could mean a loose cable, an expired certificate, or anything in between. Guessing wastes hours. But the layers you've studied give you a method: each one depends on the one below it, so you can test them in order. The first thing that fails is your answer.

7. Does the application respond correctly?curl -v6. Is the port open and listening?nc -vz / ss -ltn5. Do names resolve?dig / nslookup4. Can I reach an outside IP address?ping 1.1.1.1 / traceroute3. Can I reach my gateway?ping <gateway>2. Do I have an IP address?ip addr / ipconfig1. Is the link up?ip link / Wi-Fi status
Climb from the bottom. The first rung that fails is where to look, and everything above it is a symptom.

Your toolkit

Each tool isolates one rung of the ladder. The most useful habit is to change only one thing between tests: pinging an IP address and pinging a name differ only by DNS, so if the first works and the second doesn't, you've found your problem in two commands.

terminal
1$ ping -c 3 192.168.1.1            # is the gateway reachable?
23 packets transmitted, 3 received, 0% packet loss
3rtt min/avg/max = 1.1/1.4/1.9 ms
4
5$ dig +short learn.example          # do names resolve?
6203.0.113.8
7
8$ nc -vz learn.example 443          # is the port open?
9Connection to learn.example 443 port [tcp/https] succeeded!
10
11$ curl -sI https://learn.example    # does the application answer?
12HTTP/2 200
13content-type: text/html

Try it

What does this error tell you?

Sort each message by the layer you should investigate first.

0 of 6 sortedScore 0/0
  • “curl: (6) Could not resolve host: learn.example”

  • “ping: Destination Host Unreachable”

  • “curl: (7) Connection refused”

  • “SSL certificate problem: certificate has expired”

  • “HTTP/1.1 500 Internal Server Error”

  • “NXDOMAIN”

Try it

Network detective

Four tickets have landed in your queue. For each one, run the commands you think will help, read the output, and name the root cause. The colored dot on each command shows its layer. Start low on the ladder, and try to solve each case with as few commands as you can.

Case 1 of 4Solved 0/0

Nothing loads, but the chat app works

A developer says every website fails with “server not found”, yet their chat app, which connects to a saved IP address, works fine.

Run a command (0 used so far)

What's the root cause?

Automating the first check

The ladder logic is simple enough to code, which is how monitoring tools work. Run this and change the results to see the diagnosis move.

diagnose.py
1checks = [
2    ("link", True),
3    ("address", True),
4    ("gateway", True),
5    ("internet", True),
6    ("dns", False),
7    ("port", False),
8    ("application", False),
9]
10
11for name, passed in checks:
12    if not passed:
13        print(f"Start at: {name}")
14        break
15else:
16    print("All layers look healthy")
Output
Start at: dns

Key takeaways

  • Work from the bottom up: the first failing layer is where to look.

  • Change one thing per test, for example an IP address instead of a name.

  • Refused means the host answered. A timeout means packets are being dropped.

Lesson quiz

7 questions · pass with 5 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: model networking concepts

Use small Python programs to model packet, address, and protocol behavior. These exercises run locally in your browser and do not send network traffic.

Exercise 1

Read a ping summary

+25 XP

Read a ping summary line such as 10 packets transmitted, 7 received. Print the packet loss as a whole percentage, then healthy if it's 0, degraded if it's below 100, or down if all were lost.

  • A clean run
  • Some loss
  • Total loss
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Exercise 2

Triage an error message

+25 XP

Write the first step of an automatic triage tool. Read an error message and print which layer to check: dns, firewall or routing, service not listening, tls or unknown.

Match these phrases, ignoring case:

  • could not resolve or nxdomain → dns
  • timed out → firewall or routing
  • connection refused → service not listening
  • certificate → tls
  • A DNS failure
  • A timeout
  • A refused connection
  • A certificate problem
  • Something else
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…