Sub topic 4
Network configuration: ipconfig, hostname, and ping
This chapter assumes you can open an elevated Command Prompt and read a command's help with /?. It also assumes you know what an IP address, a default gateway, DNS, and DHCP are. Here you will use ipconfig, hostname, and ping to check a machine's network settings and test basic connectivity.
What these tools do
ipconfigshows and manages the IP configuration of the network adapters.hostnameprints the computer's name.pingsends test packets to another host and reports whether it answers and how long the answer took.
Each tool answers a different question. ipconfig tells you what the machine believes about its own network settings. ping tells you whether another device actually responds.
ipconfig
Run ipconfig with no switches to see a short summary for each adapter: IPv4 address, subnet mask, and default gateway. Add switches for more control.
| Command | Purpose |
|---|---|
| `ipconfig` | Summary of each adapter |
| `ipconfig /all` | Full detail: MAC address, DHCP status, DHCP server, DNS servers, lease times |
| `ipconfig /release` | Gives up the current DHCP lease |
| `ipconfig /renew` | Requests a new DHCP lease |
| `ipconfig /flushdns` | Clears the local DNS resolver cache |
| `ipconfig /displaydns` | Shows the contents of the DNS resolver cache |
ipconfig /all
ipconfig /release
ipconfig /renew
ipconfig /flushdnsReading the output
Look at these fields first in ipconfig /all:
- DHCP Enabled. "Yes" means the address comes from a DHCP server. "No" means it is set by hand.
- IPv4 Address. The address of this adapter.
- Default Gateway. The router used to reach other networks. A blank value means the machine has no route off its own network.
- DNS Servers. The servers used to turn names into addresses.
- Physical Address. The adapter's MAC address.
APIPA addresses
If a DHCP client cannot reach a DHCP server, Windows assigns itself an address in the 169.254.0.0/16 range. This is Automatic Private IP Addressing (APIPA). A 169.254.x.x address means DHCP failed. The machine can talk to other APIPA hosts on the same segment, but it has no gateway and cannot reach other networks.
Typical causes are a disconnected cable, a down DHCP server, or a switch port or Wi-Fi problem. Fix the cause first, then run ipconfig /renew.
Release and renew
/release and /renew apply only to adapters that use DHCP. Run them together from an elevated prompt. If you release over a remote session, you can lose your connection to the machine. On the exam, the usual scenario is a computer with a wrong or APIPA address. The fix is to release, renew, and check the result.
Flushing the DNS cache
Windows keeps recent name lookups in a cache. If a site has moved to a new address but your machine still goes to the old one, run ipconfig /flushdns. The next lookup then asks the DNS server again. Flushing the cache does not change your adapter settings.
hostname
hostname prints the computer name and nothing else.
hostnameIt is useful when you work on several machines and need to confirm which one you are on. The full output of ipconfig /all also shows it as "Host Name". To rename a computer, use System settings, not this command.
ping
ping sends ICMP echo request packets and waits for echo replies. ICMP is the Internet Control Message Protocol. Each reply shows the round-trip time in milliseconds and the TTL (time to live), which is the number of router hops the packet may still cross.
By default, Windows sends 4 requests. Useful switches:
| Switch | Meaning |
|---|---|
| `-n count` | Send this many requests |
| `-t` | Ping until stopped with Ctrl+C |
| `-a` | Resolve the address to a host name |
| `-l size` | Set the packet size in bytes |
| `-4` / `-6` | Force IPv4 or IPv6 |
ping -n 4 127.0.0.1
ping -n 4 example.comTesting in layers
Ping from the inside out so each result narrows the problem:
ping 127.0.0.1tests the local TCP/IP stack. The address is the loopback address. It never leaves the computer. If this fails, the stack is damaged or blocked.- Ping the machine's own IP address to check the adapter configuration.
- Ping the default gateway to check the local network.
- Ping an outside IP address, such as a public DNS server, to check the route to the internet.
- Ping a host name, such as
example.com, to check DNS.
If step 4 works but step 5 fails, the network path is fine and name resolution is the problem. Check the DNS servers in ipconfig /all.
Reading ping results
- Reply from ... The host answered.
- Request timed out. No reply arrived in time. The host may be off, the path may be broken, or a firewall may block ICMP.
- Destination host unreachable. A router or your own machine knows there is no route to the target.
- Ping request could not find host. DNS could not resolve the name.
Edge cases
- A failed ping does not prove the host is down. Many hosts and firewalls drop ICMP on purpose.
- A successful ping does not prove that a service, such as a web server, works. It only proves the host answers ICMP.
- Pinging a name tests DNS and connectivity together. Pinging an IP address tests connectivity alone.
Worked example
A user says the internet is down, but the Wi-Fi icon shows connected.
- Run
ipconfig /all. The adapter shows 169.254.37.8 and no gateway. This is APIPA, so DHCP failed. - Check the Wi-Fi connection and the router, then run
ipconfig /releasefollowed byipconfig /renew. - The adapter now has 192.168.1.25 and a gateway of 192.168.1.1.
- Run
ping 192.168.1.1. It replies, so the local network works. - Run
ping example.com. If it replies, the problem is solved. If it says it could not find the host, check the DNS servers and runipconfig /flushdns.
Exercise
A technician runs ipconfig /all and sees an IPv4 address of 169.254.12.4 with no default gateway. What does this mean, and what should the technician do?
Show answer
The computer could not get a lease from a DHCP server, so Windows assigned itself an APIPA address. The technician should check the cable or wireless connection and the DHCP server or router, then run ipconfig /release and ipconfig /renew and confirm that a valid address and gateway appear.
Exercise
Pinging 8.8.8.8 gets replies, but pinging example.com returns "Ping request could not find host." Which part of the setup is most likely at fault?
Show answer
DNS. Connectivity to the internet works, because the IP address answers, but the name cannot be resolved. Check the DNS server entries in ipconfig /all, try ipconfig /flushdns, and test with nslookup.