Sub topic 12
Command-line tools for diagnosis
This chapter assumes you can open a terminal on Windows and Linux, you have a Windows and a Linux guest in your lab (built in the virtual machine chapter), and you know basic networking terms such as IP address, gateway, and DNS. The goal is to use command-line tools to collect evidence about a fault before you change anything.
Why evidence comes first
The A+ troubleshooting methodology asks you to identify the problem, establish a theory, and test it before you fix anything. Command-line tools supply the test. A tool's output either supports your theory or rules it out, and each result tells you which layer to look at next.
The exam also tests these tools directly. Performance-based questions often show a terminal and ask which command to run or what an output means. Running each command yourself in the lab is the most reliable way to learn the output formats.
Walking the network path on Windows
Diagnose network faults from the machine outward, one hop at a time. Each command answers one question, and a failure tells you where to stop.
ipconfig /all
ping 127.0.0.1
ping 192.168.1.1
nslookup example.com
tracert example.comReplace 192.168.1.1 with your own default gateway, which ipconfig /all shows.
ipconfig /allshows the IP address, subnet mask, gateway, DNS servers, MAC address, and whether DHCP is in use.ping 127.0.0.1tests the local TCP/IP stack. If it fails, the problem is in the operating system's networking software, not the cable or the router.- Pinging the gateway tests the link to the local network.
nslookuptests name resolution.tracertshows each router on the way to a remote host.
Reading the results
| Observation | Likely meaning |
|---|---|
| IP address in `169.254.x.x` | The host assigned itself an address (APIPA) because no DHCP server answered. |
| Loopback ping fails | The TCP/IP stack is damaged or disabled. |
| Gateway ping fails | Cable, wireless association, switch port, or a wrong static address or mask. |
| Public IP ping works, name lookup fails | DNS is misconfigured or unreachable. |
| `tracert` shows `* * *` on one hop | That router may simply not answer ICMP. Look at whether later hops respond. |
| `tracert` stops at one hop and nothing after responds | The fault is at or just past that device. |
Test a public IP address first, and test names second. For example, ping 8.8.8.8 works whether or not DNS does. If that ping succeeds and ping example.com fails, you have isolated the fault to name resolution without touching any settings.
The same checks on Linux
A Linux guest uses different commands for the same questions.
ip addr show
ip route show
ping -c 4 192.168.1.1
resolvectl statusip addr show lists interfaces and their addresses. ip route show lists the routing table, including the default route (the line beginning default via), which is your gateway. The -c 4 option sends four pings and stops, because Linux ping runs until you interrupt it. resolvectl status shows which DNS servers systemd-resolved is using for each interface.
On some systems, ifconfig and netstat still appear in older study material. Know what they do, but expect ip and ss on current distributions.
Checking the operating system
Not every fault is a network fault. When Windows shows crashes, missing system files, or file system errors, run the repair tools in a fixed order from an elevated prompt (Command Prompt or PowerShell started as administrator).
sfc /scannow
DISM /Online /Cleanup-Image /RestoreHealth
chkdsk C: /scansfc /scannowchecks protected system files and replaces damaged ones from the local component store.DISM /Online /Cleanup-Image /RestoreHealthrepairs the component store itself. Run it when SFC reports damage it cannot fix, then run SFC again.chkdsk C: /scanperforms an online scan of the file system for errors. Adding/ffixes errors but requires the volume to be unmounted, so on the system drive it schedules the check for the next restart.
Other commands worth practicing
| Command | Purpose |
|---|---|
| `ipconfig /release` and `/renew` | Drop and request a new DHCP lease. |
| `ipconfig /flushdns` | Clear the local DNS resolver cache. |
| `netstat -an` | List connections and listening ports. |
| `pathping` | Combine ping and tracert statistics for each hop. |
| `gpupdate /force` | Reapply Group Policy settings. |
| `tasklist` and `taskkill` | List processes and end one by name or ID. |
| `net use` | Map or list network shares. |
| `diskpart` | Manage disks, partitions, and volumes. |
| `robocopy` | Copy file trees with retries and logging. |
Run each one once, even if the exam only needs you to recognize it. Seeing a lease renewed, or a port listed as LISTENING, makes the description stick.
Common errors
- Trusting one test. A successful ping does not prove an application works. Firewalls often block ICMP, so a failed ping does not prove a host is down either.
- Skipping the elevated prompt.
sfcandDISMfail with an access message if you did not run them as administrator. - Confusing
nslookupwith system resolution.nslookupqueries a DNS server directly. It can succeed while a cached or hosts-file entry still sends applications to the wrong address. - Changing several things at once. If you flush DNS, renew the lease, and reboot together, you cannot tell which step fixed the fault. Change one thing, retest, and record the result.
- Forgetting the VM's network mode. In VirtualBox, NAT, bridged, and host-only adapters give different addresses and gateways. A gateway ping that fails may be a setting on the virtual adapter, not a fault in the guest.
Exercise
A Windows workstation can browse to http://93.184.216.34 by IP address but not to http://example.com. ping 127.0.0.1 and a ping to the gateway both succeed. Which command do you run next, and what is the most likely cause?
Show answer
Run nslookup example.com to query the configured DNS server. The IP-address test shows the path to the internet works, so the likely cause is a DNS problem, such as a wrong or unreachable DNS server address. Check the DNS entries in ipconfig /all and try ipconfig /flushdns after correcting them.
Exercise
You run sfc /scannow and it reports that it found corrupt files but could not repair some of them. What do you run next, and what do you do afterward?
Show answer
Run DISM /Online /Cleanup-Image /RestoreHealth from an elevated prompt to repair the component store. Then run sfc /scannow again so it can replace the damaged files using the repaired store.