Skip to content
Tutorials Center
My learning

Topics

Lesson 21 of 36 ยท Service and OS Detection

Aggressive Scan (-A) and Traceroute

Learn what Nmap -A bundles (-sV, -O, -sC, --traceroute), when to use it on your own network, how traceroute maps hops, and how to read the result.

By now you know three separate detections: services with -sV, operating systems with -O, and (coming in the next chapter) default scripts with -sC. Typing all of them every time gets tedious, so Nmap offers a shortcut: -A, the "aggressive" scan. It also adds --traceroute, which maps the network path to the target.

"Aggressive" does not mean hostile. It means noisy and thorough: lots of probes, more time and more traffic. That is perfect for a lab host you own and a poor choice for a fragile production device you have not announced a scan for.

Output below is example output from a lab network, shown read-only. The Python blocks are stand-ins that work on pasted text.

What -A switches on

Terminal
# Example command (read-only)
sudo nmap -A 192.0.2.30
Part Equivalent Purpose
Service/version detection -sV Names products on open ports
OS detection -O Guesses the operating system
Default scripts -sC Runs safe-category NSE scripts such as http-title
Traceroute --traceroute Records the hops to the target

-A is exactly this set and nothing else. It does not change which ports are scanned (that is still the 1,000 most common by default) or the timing template. For a quick test run, use it on a few ports:

Terminal
nmap -A -p 22,80,443 192.0.2.30

Example output (illustrative):

TEXT
PORT    STATE SERVICE  VERSION
22/tcp  open  ssh      OpenSSH 9.6p1 Ubuntu 3ubuntu13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   256 3a:bc:... (ECDSA)
|_  256 9f:21:... (ED25519)
80/tcp  open  http     nginx 1.24.0 (Ubuntu)
|_http-title: Lab status page
|_http-server-header: nginx/1.24.0 (Ubuntu)
443/tcp open  ssl/http nginx 1.24.0 (Ubuntu)
| ssl-cert: Subject: commonName=lab.example.test
| Not valid after:  2027-02-01T10:00:00
Device type: general purpose
Running: Linux 5.X|6.X
OS details: Linux 5.4 - 6.2
Network Distance: 2 hops

TRACEROUTE (using port 443/tcp)
HOP RTT     ADDRESS
1   0.35 ms 192.0.2.1
2   0.61 ms 192.0.2.30

Lines beginning with | or |_ come from scripts. A single scan now answers "what is it, what does it run and how do I reach it".

Traceroute: mapping the path

Every IP packet carries a TTL (time to live). Each router decrements it by one, and a router that reduces it to zero drops the packet and sends back an ICMP "time exceeded" message. A traceroute exploits this: send packets with TTL 1, 2, 3, ... and record who answers at each step.

flowchart LR
    Me["Scanner"] -->|"TTL=1"| R1["Router 1<br/>192.0.2.1"]
    R1 -.->|"time exceeded"| Me
    Me -->|"TTL=2"| T["Target<br/>192.0.2.30"]
    T -.->|"normal reply"| Me

Increasing the TTL reveals one more router per probe.

Nmap's --traceroute is smarter than the classic tool. It first learns the distance to the target from an ordinary probe, then sends only as many TTL-limited probes as needed, and it probes many hosts in parallel. It uses the port and protocol that already produced a reply (here TCP port 443), because those packets are the least likely to be filtered. Useful notes:

  • If a router does not answer, the line shows a gap (... 4-6 Hops are not responding), as many networks filter ICMP.
  • RTT (round-trip time) per hop helps locate slow links.
  • The path can differ between runs because of load balancing.

Simulating the TTL idea

Python Stand-in: a TTL-limited path

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Reading -A output with code

When you run -A across many hosts, you will want the interesting lines only. The stand-in extracts the services, OS line and hop count from pasted output.

Python Stand-in: summarise an -A report

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

When to use -A, and when not to

Good uses:

  • A first look at a new lab machine or a freshly built server you own.
  • A one-off audit of a small subnet, with the owners informed.
  • Learning: the output shows how many features fit together.

Think twice:

  • On very large ranges, -A is slow because every open port gets probes and scripts.
  • On production gear without a maintenance window. Probes and scripts can briefly load services or fill logs, and an intrusion detection system will notice (see Firewalls and IDS).
  • When you need predictable timing. Combine it with a timing template and a port list.

Instead of -A you can pick the pieces you need, for example -sV --traceroute without OS detection.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which set of options does -A enable?

    -A bundles version detection, OS detection, default scripts and traceroute. It does not change port selection or timing.
  2. 2. How does a traceroute discover the routers on a path?

    A router that drops a packet because its TTL hit zero reports itself via ICMP, so each TTL value reveals one more hop.
  3. 3. What does a gap of non-responding hops in traceroute output usually mean?

    Many networks block or rate-limit ICMP time-exceeded messages, so intermediate hops stay silent even though traffic passes.
  4. 4. Why is -A a poor default for a large production range?

    Aggressive means many probes and scripts per open port. Use it deliberately, with permission and a time window.

Summary

  • -A = -sV + -O + -sC + --traceroute: thorough, slower and noisier.
  • Traceroute uses growing TTL values and ICMP "time exceeded" replies to list hops.
  • Lines starting with | come from NSE scripts; extract what you need with code.
  • Choose individual options when you want control over time and traffic.

Next: Introduction to the Nmap Scripting Engine