Your Gateway to a Career in Network Engineering
Module 7: Command-Line Diagnostics
The command prompt is the network technician's stethoscope. It provides a set of powerful, built-in tools that allow you to quickly diagnose the health of your network without any fancy software. Mastering these four fundamental commands is essential for applying troubleshooting methodologies and quickly isolating problems.
ipconfig / ifconfig
What it Does: Displays the current TCP/IP network configuration values on your own computer.
How to Use It: On Windows, type ipconfig /all. On Linux/macOS, type ifconfig or ip addr.
C:\> ipconfig
Windows IP Configuration
Ethernet adapter Ethernet0:
Connection-specific DNS Suffix . :
IPv4 Address. . . . . . . . . . . : 192.168.10.10
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.10.1
What it Tests (OSI Layers 1, 2, 3):
- IPv4 Address: Do I have a valid IP address, or do I have a
169.254.x.xAPIPA address (meaning DHCP failed)? - Subnet Mask: Is my subnet mask correct for my network?
- Default Gateway: Do I know the address of my router to get off the local network?
Use this first to: Verify a computer has a valid IP address and knows its gateway.
ping
What it Does: Sends an ICMP "Echo Request" message to a target host to test basic connectivity.
How to Use It: ping [ip_address_or_hostname] (e.g., ping 8.8.8.8)
C:\> ping 8.8.8.8
Pinging 8.8.8.8 with 32 bytes of data:
Reply from 8.8.8.8: bytes=32 time=12ms TTL=118
Reply from 8.8.8.8: bytes=32 time=11ms TTL=118
Request timed out.
Reply from 8.8.8.8: bytes=32 time=12ms TTL=118
What it Tests (OSI Layer 3):
- Reply from...: Confirms that there is a two-way path between your device and the target.
- time=Xms: This is the Round-Trip Time (RTT), or latency. Low is good; high or inconsistent times indicate network congestion.
- Request timed out: This indicates packet loss. The target did not respond in time.
- Destination host unreachable: Your local router doesn't know how to get to the destination.
Use this to: Check network connectivity, measure latency, and identify packet loss.
tracert / traceroute
What it Does: Maps the path a packet takes, hop-by-hop, from your computer to a destination host.
How to Use It: On Windows, type tracert [ip_or_hostname]. On Linux/macOS, type traceroute [ip_or_hostname].
C:\> tracert 8.8.8.8
Tracing route to dns.google [8.8.8.8]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 192.168.10.1
2 8 ms 7 ms 7 ms 10.100.0.1
3 * * * Request timed out.
4 12 ms 11 ms 12 ms dns.google [8.8.8.8]
Trace complete.
What it Tests (OSI Layer 3 Routing):
- Each numbered line represents one "hop" (a router) along the path.
- The first hop is always your default gateway.
- The three time columns show the latency to that specific hop.
- A line of asterisks (
* * *) indicates that a router in the path did not respond, possibly due to a firewall rule. - If the trace stops and never completes, it pinpoints where in the path the routing failure is occurring.
Use this to: Identify the exact point of failure when you can't reach a destination.
nslookup
What it Does: Queries the Domain Name System (DNS) to resolve a hostname to an IP address, or vice-versa.
How to Use It: nslookup [hostname] (e.g., nslookup www.mubashercyber.com)
C:\> nslookup www.cisco.com
Server: UnKnown
Address: 192.168.10.1
Non-authoritative answer:
Name: e144.dscb.akamaiedge.net
Address: 23.218.148.51
Aliases: www.cisco.com
What it Tests (OSI Layer 7):
- Server / Address: Shows which DNS server your computer used to perform the lookup.
- Name / Address: Shows the IP address(es) associated with the name you queried.
- If it returns "Non-existent domain" or times out, you have a DNS problem.
Use this to: Diagnose DNS issues. If you can ping 8.8.8.8 but not ping www.google.com, the problem is almost always DNS.