Sub topic 6
Ping by IP address versus ping by name
This chapter assumes you can open a command prompt, know what an IP address, a default gateway, and a DNS server are, and have read ipconfig and ping output before. Here you will use the difference between pinging an address and pinging a name to decide whether a fault lies in connectivity or in name resolution.
Two different jobs
A ping to an IP address tests only whether packets can travel to that host and back. A ping to a name such as example.com does two things in sequence:
- The computer asks its DNS server to turn the name into an IP address. This is name resolution.
- The computer sends ICMP echo requests to the address it received.
If step 1 fails, no packet ever leaves for the destination. The failure says nothing about the route to it. Comparing the two kinds of ping lets you tell the problems apart.
The comparison test
Run both pings in turn:
ping 8.8.8.8
ping example.com| `ping 8.8.8.8` | `ping example.com` | Likely meaning |
|---|---|---|
| Replies | Replies | Connectivity and DNS both work. |
| Replies | "Ping request could not find host" | Connectivity works. Name resolution is broken. |
| Times out | Fails to resolve | Connectivity is broken, and DNS may be unreachable too. |
| Times out | Replies | The remote host may block ICMP only for that address. Check the other results. |
The second row is the most common one worth recognizing. The Windows message is "Ping request could not find host example.com. Please check the name and try again." Linux and macOS print "Name or service not known" or "cannot resolve". These messages mean DNS failed. They do not mean the network is down.
Finding the cause of a DNS failure
When the address works but the name does not, look at the DNS servers your computer is using:
ipconfig /allCheck the "DNS Servers" lines. Common causes are an empty or wrong DNS server, a DNS server that is unreachable, or a stale local cache. You can ping the DNS server's address to check that it is reachable. Then clear the cache and try again:
ipconfig /flushdns
ping example.comPinging the DNS server can still be misleading. A server may drop ICMP and yet answer DNS queries normally, so a timeout there does not prove that DNS is down.
Reading the resolved address
When a name ping succeeds, the first reply line shows the address that DNS returned:
Pinging example.com [93.184.216.34] with 32 bytes of data:The address in brackets is the result of name resolution. Two details are worth noting. A name can return different addresses at different times, because many sites spread traffic across several servers. A name can also return an IPv6 address on some systems, which then makes the test an IPv6 test. On Windows, add -4 to force IPv4:
ping -4 example.comExercise
You run ping 8.8.8.8 and receive four replies. You then run ping example.com and see "Ping request could not find host example.com." What does this tell you, and what do you check next?
Show answer
Connectivity to the internet works, because the address replied. The fault is in name resolution. Next, run ipconfig /all to check the DNS servers listed for the adapter. Then try ipconfig /flushdns and ping the name again.
Exercise
A ping to a name shows Pinging example.com [93.184.216.34] but every request times out. Is this a DNS problem? Why or why not?
Show answer
No. The name resolved to an address, so DNS worked. The timeouts point to a connectivity problem on the path, or to the destination dropping ICMP. Compare with a ping to a different known-good address.