Sub topic 17
Using ping, ipconfig, nslookup, and tracert
This chapter assumes you know what an IP address, default gateway, DHCP, and DNS do, and that you can open a command prompt on Windows. The four tools here let you work out where a connection fails, one layer at a time.
ipconfig: read the configuration first
Start with ipconfig /all. It shows each adapter's IP address, subnet mask, default gateway, DHCP server, and DNS servers.
ipconfig /allCheck the address before anything else:
- An address in 169.254.0.0/16 is APIPA. The computer asked for a DHCP lease and got no answer.
- A missing gateway means the computer can't leave its own subnet.
- A DNS server that is blank or wrong breaks name lookups while raw IP traffic still works.
If the address looks wrong, release the lease and request a new one.
ipconfig /release
ipconfig /renewping: test reachability in order
ping sends ICMP echo requests and reports whether replies come back. Test from the inside out, so the first failure tells you where the fault is.
ping 127.0.0.1
ping 192.168.1.1
ping example.comReplace 192.168.1.1 with your own router's address.
| Test | A failure suggests |
|---|---|
| 127.0.0.1 (loopback) | A problem with the local TCP/IP stack or network driver |
| Default gateway | A bad cable, Wi-Fi link, wrong address, or router problem |
| example.com | A DNS problem or an internet outage |
If the gateway answers but the name fails, ping a public IP address such as 8.8.8.8. A reply from the IP but not the name points to DNS.
nslookup: isolate DNS
nslookup asks the configured DNS server to resolve a name.
nslookup example.comIf it returns an address, DNS is working. If it times out or says the server can't be found, check the DNS entries from ipconfig /all. Try another resolver, such as your router or a public one.
tracert: find where packets stop
tracert lists each router hop between you and the destination, with round-trip times.
tracert example.comRows of * with "Request timed out" mean a hop didn't answer. Some routers drop these probes on purpose, so judge by whether later hops respond. If every hop after one point fails, the problem is at or beyond that hop. A sudden jump in latency shows where slowness begins.
Exercise
A laptop shows the address 169.254.12.7. Pinging 127.0.0.1 succeeds. Which tool and command do you run next, and what are you trying to fix?
Show answer
Run ipconfig /release and then ipconfig /renew. The 169.254.x.x address is APIPA, so no DHCP server answered. The successful loopback ping shows the local TCP/IP stack is fine. Renewing requests a new lease. If it fails again, check the cable or Wi-Fi connection and whether the router's DHCP service is on.
Exercise
You can ping 8.8.8.8 but not example.com. Which tool narrows the problem, and what does it point to?
Show answer
Run nslookup example.com. Since the IP address is reachable, the connection works, and the failure is name resolution. Check the DNS servers listed by ipconfig /all.