Command-Line
Networking Tools
Master the essential command-line utilities: ping, traceroute, and nslookup/dig to diagnose networks and investigate connectivity like a cybersecurity professional.
What Are Networking Tools?
Command-line networking tools are text-based utilities built into your operating system that let you probe, diagnose, and investigate how data moves across networks. Instead of clicking through a graphical interface, you type a command and read structured output.
Why Do They Matter in Cybersecurity?
Every cybersecurity analyst relies on these tools daily. They are the first line of investigation when something goes wrong on a network: a website is unreachable, traffic is being rerouted, or a domain has been hijacked.
Where Tools Fit in the Network Stack
How ping Works
Reading ping Output
PING example.com (93.184.216.34): 56 data bytes
64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=11.6 ms
64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=11.4 ms
64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=11.8 ms
64 bytes from 93.184.216.34: icmp_seq=3 ttl=56 time=11.5 ms
--- example.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss
round-trip min/avg/max = 11.4/11.6/11.8 ms
How traceroute Works
Reading traceroute Output
traceroute to example.com (93.184.216.34), 30 hops max
1 192.168.1.1 1.2 ms 1.0 ms 1.1 ms
2 10.0.0.1 8.4 ms 8.1 ms 8.3 ms
3 72.14.215.85 12.6 ms 12.4 ms 12.7 ms
4 * * *
5 93.184.216.34 14.2 ms 14.0 ms 14.3 ms
How nslookup and dig Work
Key DNS Record Types
| Record | Purpose | Example Value |
|---|---|---|
| A | Maps domain to IPv4 address | 93.184.216.34 |
| AAAA | Maps domain to IPv6 address | 2606:2800:220:1::248 |
| MX | Mail server for the domain | mail.example.com |
| CNAME | Alias pointing to another domain | www → example.com |
| NS | Authoritative nameserver | ns1.example.com |
nslookup vs dig
| Feature | nslookup | dig |
|---|---|---|
| Output Style | Simple, human-readable | Detailed, script-parseable |
| Record Detail | Basic (name + IP) | Full (TTL, flags, authority) |
| Availability | Windows, macOS, Linux | macOS, Linux (install on Win) |
| Best For | Quick lookups | In-depth investigation |
| Cybersecurity Use | Basic recon | Preferred for forensics |
How to Diagnose a Network Issue
Example 1: Checking Server Status
Scenario: Users report they cannot reach the company website at company.com. You are the first responder.
PING company.com (203.0.113.50): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
--- company.com ping statistics ---
4 packets transmitted, 0 received, 100% packet loss
Example 2: Finding the Bottleneck
Scenario: The website loads but is extremely slow. You run traceroute to locate the delay.
1 192.168.1.1 1.1 ms 1.0 ms 1.2 ms
2 10.0.0.1 5.3 ms 5.1 ms 5.4 ms
3 isp-router.net 185.2 ms 190.1 ms 187.5 ms
4 backbone.net 186.0 ms 184.8 ms 185.3 ms
5 203.0.113.50 187.4 ms 186.9 ms 188.1 ms
Example 3: Investigating DNS Hijacking
Scenario: Employees visiting bank.example.com see a phishing page. You suspect DNS poisoning.
;; ANSWER SECTION:
bank.example.com. 300 IN A 185.100.87.202
;; Expected IP should be: 203.0.113.25
Common Mistakes to Avoid
Summary: Tool Comparison
| Tool | Protocol | Key Output | Use When |
|---|---|---|---|
| ping | ICMP | RTT, packet loss | "Is it reachable?" |
| traceroute | ICMP / UDP | Hop-by-hop path | "Where does it break?" |
| nslookup | DNS (UDP 53) | Name → IP | "Quick DNS check" |
| dig | DNS (UDP 53) | Full DNS record | "Deep DNS forensics" |
Question 1 of 5
What protocol does ping use to test connectivity?
Question 2 of 5
In a traceroute output, what does * * * at a particular hop most likely indicate?
Question 3 of 5
A security analyst runs dig example.com A and sees the IP address has changed from the expected value. What type of attack might this indicate?
Question 4 of 5
You ping a server and receive replies with time=350 ms. Which of the following is the best next step?
Question 5 of 5
Which DNS record type would you query to find the mail server responsible for a domain?