Sub topic 3
Command-Line Tools: ping, ipconfig, nslookup, tracert
This chapter assumes you know what an IP address, subnet mask, default gateway, DHCP server, and DNS server do, and that you can open a Command Prompt in Windows. You also need the six-step troubleshooting methodology from the first chapter. The four tools here are how you carry out the "establish a theory" and "test the theory" steps on a network problem.
The A+ Core 1 exam asks which tool to run, in what order, and what the output means. Learn the pattern in each tool's output, not just the syntax.
Working model: test from the inside out
A connection passes through several layers before a web page loads. Your computer's TCP/IP software must work. The local network must carry the packet to the default gateway. The router must forward it to the internet. DNS must turn a name into an address. Each tool tests one or more of these links. Testing in order, from your own computer outward, tells you which link broke.
ping
ping sends ICMP echo request packets to a target and waits for echo replies. ICMP (Internet Control Message Protocol) is a protocol used for diagnostics and error messages. Each reply shows the round-trip time in milliseconds, and the summary shows how many packets were lost.
The sequence from the plan runs four pings in order:
ping 127.0.0.1
ping 192.168.1.1
ping 8.8.8.8
ping example.comReplace 192.168.1.1 with your own default gateway, which you find with ipconfig.
| Target | What a reply proves | What a failure suggests |
|---|---|---|
| 127.0.0.1 (loopback) | The TCP/IP software on this computer works | Damaged network stack or driver, or a firewall rule blocking ICMP locally |
| Default gateway | The computer reaches the local network and the router | Bad cable, disabled adapter, wrong IP or subnet mask, Wi-Fi not connected |
| Public IP such as 8.8.8.8 | The router forwards traffic to the internet | Router has no upstream link, ISP outage, wrong default gateway |
| Hostname | DNS resolves the name and the host replies | DNS server unreachable or wrong, while the IP ping worked |
The key diagnostic is the last two rows together. If ping 8.8.8.8 succeeds and ping example.com fails with "could not find host," the network works and DNS is the problem.
Reading ping results
- Reply from ...: the host answered. Note the
time=value. Consistently high or highly variable times suggest congestion or a weak wireless signal. - Request timed out: no reply arrived in time. The host may be down, a device may be dropping the packets, or a firewall may block ICMP.
- Destination host unreachable: a router or your own computer reports it has no route to the target. If the message comes from your own IP address, the problem is local, often a missing gateway.
- Ping request could not find host: DNS could not resolve the name.
- Packet loss: some of the four default packets were lost. Intermittent loss points to a failing cable, interference, or an overloaded link.
Useful switches
ping -t hostpings continuously until you press Ctrl+C. Use it while you reseat a cable or move closer to an access point, so you see the moment the link recovers.ping -n 10 hostsends a set number of packets.ping -4 hostorping -6 hostforces IPv4 or IPv6.
ipconfig
ipconfig shows and changes the IP configuration of the computer. Run it first when you suspect an addressing problem, because it shows what the computer actually has, not what it should have.
ipconfig /allPlain ipconfig shows the address, mask, and gateway for each adapter. The /all switch adds the details you need for most faults:
- Physical (MAC) address of the adapter
- Whether DHCP is enabled
- IPv4 address and subnet mask
- Default gateway
- DHCP server address and lease times
- DNS server addresses
What to look for
| Observation | Meaning |
|---|---|
| Address in 169.254.0.0/16 | APIPA (Automatic Private IP Addressing). The computer asked for a DHCP lease, got no answer, and gave itself an address. It can talk to other APIPA hosts on the same segment but not to the internet. |
| Correct network but no default gateway | Local traffic works, anything outside the subnet fails. |
| Address on the wrong subnet | A static address left over from another network, or a rogue DHCP server. |
| DNS server blank or wrong | Pings by IP succeed, but names fail. |
| "Media disconnected" | The adapter sees no link, usually an unplugged cable or a disabled Wi-Fi connection. |
Releasing and renewing a lease
A DHCP lease is a temporary assignment of an IP address. These switches force the computer to give up its lease and ask for a new one:
ipconfig /release
ipconfig /renew
ipconfig /flushdns/release drops the current lease, /renew requests a new one from the DHCP server, and /flushdns clears the local DNS resolver cache. Use /flushdns when a site moved to a new address but your computer still tries the old one. Use /release and /renew after you fix the cable or Wi-Fi that caused an APIPA address. Both only affect adapters set to obtain an address automatically. A static address stays put.
nslookup
nslookup queries a DNS server directly and shows the answer. It separates a DNS problem from a connectivity problem without using ICMP.
nslookup example.comThe output first names the server that answered (the DNS server your computer uses), then lists the name and IP address it found. Typical outcomes:
- An address is returned: the DNS server resolves the name. If the browser still fails, look elsewhere, such as the browser, proxy, or the remote site.
- "DNS request timed out": the computer cannot reach its configured DNS server. Check the DNS entries in
ipconfig /alland test the path to that server withping. - "Non-existent domain": the server answered but has no record for that name. The name may be mistyped or the record may not exist.
- "Server: UnKnown": usually a missing reverse (PTR) record for the DNS server's own address. If the name still resolves, you can ignore it.
You can ask a specific server by adding it after the name, for example nslookup example.com 8.8.8.8. If the lookup works against 8.8.8.8 but fails against your configured server, your configured DNS server is the fault. The fix is to correct the DNS address in the adapter settings or the DHCP scope.
tracert
tracert traces the path packets take to a destination. It sends packets with increasing TTL (Time To Live) values. TTL is a counter that each router reduces by one. When it reaches zero the router discards the packet and reports back, which reveals that router. The result is a numbered list of hops, which are the routers along the way, with three round-trip times for each.
tracert example.comRead the output from the top:
- Hop 1 should be your default gateway. If hop 1 fails, the problem is on the local network.
- Later hops are your ISP's routers and then networks beyond it.
- The last line that responds shows where the path stops.
An asterisk (*) with "Request timed out" on a single hop does not always mean a fault. Many routers do not answer trace probes but still forward traffic. If later hops respond normally, ignore the asterisk. If every hop after a certain point times out, the break is at or just past the last hop that answered.
Large jumps in time between two hops show where latency is added, such as a slow WAN link. On Linux and macOS the equivalent command is traceroute, and on those systems ping runs until you stop it.
pathping combines tracert and ping. It traces the route, then measures packet loss at each hop over a period of time. It takes a few minutes to finish but pinpoints which hop drops packets.
Choosing the tool
| Question | Tool |
|---|---|
| What address, gateway, and DNS server does this computer have? | `ipconfig /all` |
| Is the computer reaching a specific host? | `ping` |
| Is the name resolving? | `nslookup` |
| Where along the route do packets stop? | `tracert` |
| Is the cached DNS data stale? | `ipconfig /flushdns` |
| Did the computer fail to get a DHCP lease? | `ipconfig /all`, then `/release` and `/renew` |
Worked example
A user reports that no websites load. You open a Command Prompt and work outward.
ipconfig /allshows an address of 169.254.37.12 and no gateway. This is an APIPA address, so DHCP failed.- You see the cable is unplugged from the wall jack. You reconnect it.
ipconfig /releaseandipconfig /renewreturn 192.168.1.45 with gateway 192.168.1.1.ping 192.168.1.1replies, andping 8.8.8.8replies.ping example.comreplies, so DNS works.
The theory was confirmed at step 3, and step 5 verified the full fix. After that, you would document the cause and the solution, as the methodology requires.
Common errors
- Pinging a hostname first. A failure could be DNS, routing, or the cable, so you learn little. Start with IP addresses.
- Treating a timed-out ping as proof of an outage when a firewall blocks ICMP.
- Running
/renewon a static address and expecting a change. - Forgetting that
/flushdnsclears only the local cache, not the DNS server's cache. - Ignoring a lone asterisk in
tracertwhen later hops respond.
Exercise
A user cannot open any website. ipconfig /all shows a valid address, mask, and gateway. ping 8.8.8.8 replies, but ping example.com says it could not find the host. Which tool confirms the faulty link, and what is the likely cause?
Show answer
Run nslookup example.com. Since the IP ping works, the network path is fine, so the fault is name resolution. The DNS server entry is probably wrong or the server is unreachable. Correct the DNS server address in the adapter settings or DHCP scope, then run ipconfig /flushdns and test again.
Exercise
A computer shows the address 169.254.88.4 after boot. Name the cause and the commands you would run once you have restored the physical link.
Show answer
The address is APIPA, so the computer got no reply from a DHCP server, often because of an unplugged cable or a down DHCP service. After fixing the link, run ipconfig /release and ipconfig /renew, then confirm with ipconfig /all that the address, gateway, and DNS server are correct.