01 / 20
>_

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.

Cyber Security

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.

ping
Tests whether a host is reachable and measures round-trip time
traceroute
Maps the path packets take across routers to a destination
nslookup / dig
Queries DNS servers to resolve domain names to IP addresses

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.

1
Incident Response: quickly determine if a server is down or a network path is broken
2
Threat Hunting: detect suspicious DNS changes or unexpected routing through foreign networks
3
Forensics: gather evidence about network infrastructure during an investigation

Where Tools Fit in the Network Stack

Application Layer nslookup / dig (DNS queries) Transport Layer TCP / UDP ports Network Layer (IP) ping (ICMP) & traceroute (TTL) Data Link Layer Ethernet frames, MAC addresses Physical Layer (cables, signals)

How ping Works

Your Computer Target Server ICMP Echo Request ICMP Echo Reply Round-Trip Time (RTT)

Reading ping Output

$ ping -c 4 example.com
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
ttl=56
Time-to-Live: max hops before the packet is discarded
time=11.6 ms
Round-trip time: lower is better; >200 ms signals problems
0% loss
Packet loss: any loss suggests congestion or firewall blocking

How traceroute Works

You Router 1 TTL=1 Router 2 TTL=2 Router 3 TTL=3 Target TTL expired! Sends back reply Incrementing TTL reveals each hop Each router that decrements TTL to 0 sends an ICMP Time Exceeded message

Reading traceroute Output

$ traceroute example.com
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
Hop Number
Each row = one router along the path (1 is your gateway)
Three Times
Three probe attempts per hop show consistency or variance
* * *
Asterisks mean the router did not respond (firewall or ICMP blocked)

How nslookup and dig Work

Your Machine DNS Server 8.8.8.8 93.184.216.34 IP Address "example.com?" A Record DNS Resolution: Domain Name → IP Address

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

1
Start with ping: check if the target host is reachable at all. Note the RTT and packet loss percentage.
2
Run nslookup/dig: verify the domain resolves to the expected IP address. Compare against known-good records.
3
Use traceroute: if ping fails or shows high latency, trace the path to find where the problem occurs.
4
Analyze the hop: identify the problematic router. Is it your local network, your ISP, or a remote network?
5
Document findings: record timestamps, outputs, and observations for your incident report.

Example 1: Checking Server Status

Scenario: Users report they cannot reach the company website at company.com. You are the first responder.

$ ping -c 4 company.com
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.

$ traceroute company.com
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.

$ dig bank.example.com A

;; ANSWER SECTION:
bank.example.com. 300 IN A 185.100.87.202

;; Expected IP should be: 203.0.113.25

Common Mistakes to Avoid

✕ Assuming ping failure = server down
Many servers and firewalls block ICMP packets. A failed ping does not always mean the server is offline: the website may still be accessible via HTTP.
✕ Ignoring * * * in traceroute
Asterisks often just mean a router doesn't respond to ICMP, not that it's broken. Only diagnose a problem if latency spikes or the route ends prematurely.
✕ Using only one DNS tool
nslookup gives minimal info. Always verify with dig during investigations to see TTLs, authority sections, and full record chains.

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?