NETWORK INCIDENTS

Ping Works but Websites Don't? It's Probably DNS (Here's How to Prove It)

Network+ 3.4 Name resolution: DNSNetwork+ 5.1 Troubleshooting methodologyNetwork+ 5.5 Command-line tools: dig, ping

The websites in your homelab stop loading. Not one of them, all of them. But the network looks fine, and ping still works. Let's find out what actually broke.

A homelab client can ping the web server by its address, but loading the site by name fails. The client, a router, a web server and the homelab's DNS server, each in its own container.

The symptom. From the client, curl http://web.homelab.test fails, but ping 10.0.20.80 works.

The lab

Here is the lab. A client sits on the home network behind router r1. Past the router, a switch connects two servers: a DNS server and a web server. To load the website, the client first asks the DNS server what address the name web.homelab.test belongs to, then connects to that address.

The symptom

on client
curl -m 5 http://web.homelab.test
curl: (6) Could not resolve host: web.homelab.test (Could not contact DNS servers)
What this shows

Start with the thing that's broken: loading the site. curl is a good first tool because it shows the error a browser would hide. And the error is specific. Could not resolve host, could not contact DNS servers. curl never got as far as connecting to the web server. It failed at the step before: turning the name into an address.

on client
ping -c 3 10.0.20.80
PING 10.0.20.80 (10.0.20.80) 56(84) bytes of data.
64 bytes from 10.0.20.80: icmp_seq=1 ttl=63 time=0.048 ms
64 bytes from 10.0.20.80: icmp_seq=2 ttl=63 time=0.042 ms
64 bytes from 10.0.20.80: icmp_seq=3 ttl=63 time=0.037 ms

--- 10.0.20.80 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2030ms
rtt min/avg/max/mdev = 0.037/0.042/0.048/0.004 ms
What this shows

So skip the name and use the address. A ping to the web server at 10.0.20.80 gets three replies out of three, zero percent loss. The web server is up, and the path to it through the router works. Whatever is wrong is about names, not the network.

Finding the cause

on client
cat /etc/resolv.conf
nameserver 10.0.20.53
search homelab.test
What this shows

The next question is where the client sends its name lookups. On Linux that's in resolv.conf. The nameserver line says 10.0.20.53, the DNS server.

on client
dig web.homelab.test
;; communications error to 10.0.20.53#53: connection refused
;; communications error to 10.0.20.53#53: connection refused
;; communications error to 10.0.20.53#53: connection refused

; <<>> DiG 9.20.23 <<>> web.homelab.test
;; global options: +cmd
;; no servers could be reached
What this shows

dig asks that DNS server directly and reports exactly what happens. Three attempts, and each one ends in a communications error to 10.0.20.53 on port 53: connection refused. Then, no servers could be reached.

on client
ping -c 3 10.0.20.53
PING 10.0.20.53 (10.0.20.53) 56(84) bytes of data.
64 bytes from 10.0.20.53: icmp_seq=1 ttl=63 time=0.058 ms
64 bytes from 10.0.20.53: icmp_seq=2 ttl=63 time=0.036 ms
64 bytes from 10.0.20.53: icmp_seq=3 ttl=63 time=0.035 ms

--- 10.0.20.53 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2051ms
rtt min/avg/max/mdev = 0.035/0.043/0.058/0.010 ms
What this shows

Connection refused is worth a second look. Something at that address answered, just not with DNS. A ping to 10.0.20.53 gets three replies out of three. The DNS server's machine is up and reachable. It's the DNS service on it that isn't answering.

The fix

on netlab
docker ps -a --filter name=coredns --format "table {{.Names}}\t{{.Status}}"
NAMES                   STATUS
clab-dns-down-coredns   Exited (0) 28 seconds ago
What this shows

In this homelab, DNS runs in a container on the Docker host. docker ps with the a flag lists stopped containers too, filtered here to the DNS one and trimmed to its name and status. The status says Exited. The DNS service isn't running.

on netlab
docker start clab-dns-down-coredns
clab-dns-down-coredns
What this shows

docker start brings it back.

on netlab
docker ps -a --filter name=coredns --format "table {{.Names}}\t{{.Status}}"
NAMES                   STATUS
clab-dns-down-coredns   Up 5 seconds
What this shows

In this homelab, DNS runs in a container on the Docker host. docker ps with the a flag lists stopped containers too, filtered here to the DNS one and trimmed to its name and status. The status says Exited. The DNS service isn't running.

Verifying

on client
dig +short web.homelab.test
10.0.20.80
What this shows

Back on the client, the same lookup. dig with plus short prints just the answer, and the answer is 10.0.20.80, the web server.

on client
curl -m 5 http://web.homelab.test
<!doctype html>
<title>homelab dashboard</title>
<h1>homelab dashboard</h1>
<p>It works.</p>
What this shows

And the same curl that failed at the start now returns the page. It works.

Why ping still worked

So why did ping keep working the whole time? Because the ping was given an address. It never had to ask anyone what a name meant, so it never touched DNS. Anything that starts from a name, a browser, curl, an app connecting to its database, needs DNS first. When DNS stops, all of those fail at once, while every test that uses an address keeps passing. That's what makes this one confusing.

If addresses work but names don't, check DNS

When addresses work but names don't, check DNS before anything else. Look at resolv.conf to see which server the machine asks, then use dig to see whether that server answers.

Try it yourself

The whole lab runs on your own computer with Docker and containerlab: get it on GitHub, then ./lab.sh up and ./lab.sh break. Setup steps are on Run the labs.