Lesson 7 of 11
Network Reconnaissance with CLI Tools
Security professionals regularly use command-line networking tools to diagnose issues, investigate incidents, and perform reconnaissance. These tools are equally important for attackers and defenders - understanding them from both perspectives is essential.
Essential Network CLI Commands
# ping - Test host reachability and measure latency
ping -c 4 google.com # Send 4 ICMP echo requests
ping -c 1 192.168.1.1 # Test gateway reachability
# Security note: Some hosts block ICMP - absence of response != host down
# traceroute - Map the network path to a destination
traceroute google.com # Shows each hop, latency at each router
traceroute -T -p 443 google.com # TCP traceroute on port 443 (bypasses ICMP blocks)
# Security use: Identify routing anomalies, detect traffic redirection
# netstat / ss - Show active connections and listening ports
ss -tlnp # TCP listening ports with process names
ss -anp | grep ESTABLISHED # All established connections
netstat -an | grep :22 # Who is connected to SSH
# Security use: Detect unauthorized services or malware callbacks
# dig - DNS investigation
dig example.com A # IPv4 addresses
dig example.com MX # Mail servers
dig +short example.com # Short output
dig @8.8.8.8 example.com # Query specific DNS server (Google)
# whois - Domain and IP registration information
whois example.com # Domain registration info
whois 93.184.216.34 # IP address ownership (who owns this IP?)Incident Investigation with CLI Tools
# Scenario: Server is acting strangely - investigate active connections
# Step 1: Check all active network connections
ss -antp | grep ESTABLISHED
# Look for: connections to unknown IPs, unexpected outbound connections
# Step 2: Find processes listening on all ports
ss -tlnp
# Look for: services listening on unexpected ports
# Step 3: Check for suspicious outbound DNS queries
# Monitor DNS traffic
tcpdump -n port 53
# Step 4: Identify which process owns a suspicious connection
# Connection to 185.220.101.47:443 found - identify the process:
ss -tp | grep 185.220.101
lsof -i TCP:443 | grep 185.220.101
# Step 5: Check ARP table for poisoning indicators
arp -a
# Warning: Two different IPs mapping to the same MAC = ARP spoofingCommon Mistakes
- Using only ping to check host availability - many hosts block ICMP but still have open TCP ports; use nmap instead
- Not running ss/netstat regularly as part of security monitoring - unexpected listening services or outbound connections often indicate compromise
- Trusting WHOIS data completely - IP ownership data is often outdated; cloud IPs (AWS, Azure, GCP) are owned by cloud providers, not the actual attacker
Tip
Tip
Practice Network Reconnaissance with CLI Tools in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).
Practice Task
Note
Practice Task - (1) Write a working example of Network Reconnaissance with CLI Tools from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Network Reconnaissance with CLI Tools is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.
Key Takeaways
- Security professionals regularly use command-line networking tools to diagnose issues, investigate incidents, and perform reconnaissance.
- Using only ping to check host availability - many hosts block ICMP but still have open TCP ports; use nmap instead
- Not running ss/netstat regularly as part of security monitoring - unexpected listening services or outbound connections often indicate compromise
- Trusting WHOIS data completely - IP ownership data is often outdated; cloud IPs (AWS, Azure, GCP) are owned by cloud providers, not the actual attacker
Finished this lesson?