Sub topic 3
Command-line tools: ping, ipconfig, nslookup, tracert
This chapter assumes you know what an IP address, a default gateway, DHCP, and DNS do, and that you can open a Windows command prompt. You will use four tools to find where a connection fails. The A+ Core 1 exam often asks which command to run next or what an output means.
Work from the inside out
Each tool tests one layer of the path between your computer and a website. Test the closest layer first, then move outward. The first failure tells you where to look.
ping
ping sends a small test message (an ICMP echo request) to an address and waits for a reply. It reports whether a reply came back and how long it took.
ping 127.0.0.1
ping 192.168.1.1
ping 8.8.8.8
ping example.comEach line tests a further point:
127.0.0.1is the loopback address. It never leaves your computer. A reply shows the local TCP/IP stack works.192.168.1.1stands for your default gateway, usually the router. Use your own gateway address here. A reply shows your local network works.8.8.8.8is a public IP address. A reply shows traffic can cross the internet.example.comis a hostname. A reply shows DNS can turn names into addresses.
If the third ping works and the fourth fails, the network is fine and name resolution is the fault.
ipconfig
ipconfig shows and changes your IP settings.
ipconfig /allThe output lists each adapter's IP address, subnet mask, default gateway, DHCP server, and DNS servers. Check these first:
- An address in 169.254.0.0/16 is an APIPA address. Windows assigns it to itself when it cannot get a lease from DHCP.
- A gateway that is blank or in a different subnet explains why nothing outside the local network works.
- A wrong DNS server explains why names fail while IP addresses work.
These commands refresh the configuration:
ipconfig /release
ipconfig /renew
ipconfig /flushdns/release drops the current DHCP lease. /renew requests a new one. /flushdns clears the cached name entries, which helps when a site moved to a new address.
nslookup and tracert
nslookup asks your configured DNS server to resolve a name. tracert lists each router (hop) between you and the target.
nslookup example.com
tracert example.comIf nslookup returns an address, DNS works. If it times out or reports that the server is unknown, check the DNS server settings from ipconfig /all. In tracert output, the last hop that answers is the last point that works. A row of * * * followed by "Request timed out" means that hop did not reply. If every later hop also fails, the problem is at or just past that point.
Quick reference
| Symptom | Likely cause | Tool to confirm |
|---|---|---|
| 169.254.x.x address | No DHCP lease | `ipconfig /all`, then `/release` and `/renew` |
| Gateway ping fails | Local network fault | `ping` the gateway |
| IP ping works, name ping fails | DNS fault | `nslookup` |
| Traffic stops partway | Router or route fault | `tracert` |
Exercise
A user can ping 8.8.8.8 successfully but cannot ping example.com. Which command should you run next, and what do you expect to find?
Show answer
Run nslookup example.com. The internet route works, so the likely fault is DNS. Expect a timeout or an error, which points to a wrong or unreachable DNS server. Check the DNS servers in ipconfig /all.
Exercise
ipconfig /all shows the address 169.254.12.40 and no default gateway. What happened, and which commands might fix it after you check the cable or Wi-Fi?
Show answer
The computer could not reach a DHCP server and assigned itself an APIPA address. After you restore the link, run ipconfig /release and then ipconfig /renew to request a new lease.