Skip to content
Tutorials Center
My learning

Topics

Lesson 4 of 36 ยท Getting Started

Your First Nmap Scan

Run your first Nmap scan against localhost, read what each line of the report means, and try a tiny scanner simulation that prints Nmap-style results.

Time for the real thing. In this lesson you will run the simplest possible scan on your own machine, read the result line by line, and then try a small simulation that prints the same kind of report. By the end you will know how an Nmap command is built and what to look at first in the output.

The nmap commands below are read-only here; copy them into a terminal on your own computer. The sample outputs are labelled examples with invented data. Your results will differ depending on which services run on your machine.

The simplest scan

The basic form is nmap [options] target. With no options at all:

Terminal
nmap localhost

localhost means "this computer", so nothing leaves your machine. Example output:

TEXT
Starting Nmap 7.9x ( https://nmap.org ) at 2026-11-12 10:05 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000070s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 998 closed tcp ports (conn-refused)
PORT     STATE SERVICE
631/tcp  open  ipp
8080/tcp open  http-proxy

Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds

Example output; the open ports on your machine will be different (a print service and a development web server here).

Reading the report

Go through it from top to bottom:

  1. Starting Nmap ...: the version and start time.
  2. Nmap scan report for localhost (127.0.0.1): the target, with the name and the address Nmap resolved.
  3. Host is up (0.000070s latency): host discovery succeeded. The latency is how long the probes took.
  4. Other addresses ... (not scanned): ::1: the name also has an IPv6 address; by default only the first (IPv4) is scanned. Add -6 to scan IPv6.
  5. Not shown: 998 closed tcp ports (conn-refused): Nmap summarizes boring results. By default it scanned the 1,000 most common TCP ports. Two are listed, so 998 were closed. The text in parentheses (conn-refused) is the reason Nmap concluded "closed". With a SYN scan as root it would say (reset).
  6. The table: PORT, STATE, SERVICE. The service is a guess from the port number (from a lookup file called nmap-services), not proof of what runs there.
  7. Nmap done: how many addresses were scanned, how many were up, and the elapsed time.

What Nmap did behind the scenes

Even for one command, several steps ran. Because the default behavior depends on privileges, Installing Nmap explained the difference between root and normal users.

flowchart TD
  A["nmap localhost"] --> B["Resolve the name to 127.0.0.1"]
  B --> C["Host discovery (skipped for loopback: host is up)"]
  C --> D["Scan the 1000 most common TCP ports"]
  D --> E["Group the closed ports"]
  E --> F["Print the report"]

Figure: the stages of a default scan.

On a different target, the discovery stage sends probes (ARP on a local network, otherwise ICMP echo, a TCP SYN to port 443 and an ACK to port 80, and an ICMP timestamp request). If none answers, Nmap says Host seems down and does not scan ports at all, which is a common first-day surprise covered in Host Discovery Overview.

Scanning a single machine other than yours

On your own network, give an address:

Terminal
nmap 192.168.1.1

(Replace it with your own router or device. Do not scan machines you do not own.) For a lab with an invented address:

TEXT
$ nmap 192.0.2.10
Nmap scan report for web01.example.net (192.0.2.10)
Host is up (0.0030s latency).
Not shown: 997 filtered tcp ports (no-response)
PORT    STATE SERVICE
22/tcp  open  ssh
80/tcp  open  http
443/tcp open  https

Here 997 ports are filtered rather than closed: a firewall drops probes silently. Compare the reason in parentheses (no-response) with the earlier conn-refused. Reasons explain how Nmap decided, and Verbosity and Reasons shows how to see them for every port.

A stand-in: a tiny scanner that prints Nmap-style output

You cannot send packets from a web page, but you can model a host and print its report with the same layout. This program holds an invented host in a dictionary, "scans" ports 1-1000 by looking each up, and formats the result the way Nmap does: grouping the boring ports and listing the rest.

Python A simulated scan 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.

Change the dictionary (add 8080: "open" or remove 443) and run it again. The layout shows why the output is easy to read: the closed ports are summarized and only the interesting ones are listed.

A stand-in: spotting the changes between two scans

A very common task is comparing today's results with last week's. Here is the idea, working on two sets of open ports:

Python What changed since the last scan?

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.

Set arithmetic like this becomes a full tool in Reporting and Automation later in the course.

Your first scan checklist

  1. Choose a target you own (localhost or a lab machine).
  2. Run nmap target and wait for Nmap done.
  3. Read the state column first: only open ports offer something to connect to.
  4. Compare the service names with what you expect to be running. An unexpected open port is a question worth asking.
  5. Note the line Not shown: ...: it tells you how many ports were filtered or closed.

Common beginner problems

  • Note: Host seems down: the target ignored the discovery probes. If you are sure it is up, skip discovery with -Pn (see Host Discovery Overview).
  • Only a few ports found: the default scan covers 1,000 ports, not all 65,535. You will learn -p in Choosing Ports.
  • Different results as root and as a normal user: different scan types are used.
  • Service names look wrong: they come from port numbers; version detection (-sV) checks what really answers.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How many TCP ports does a default Nmap scan check?

    By default Nmap scans the 1,000 most frequently used ports according to its nmap-services data.
  2. 2. What does the SERVICE column in the default output show?

    Without -sV, the service name is only looked up from the port number.
  3. 3. The report says Not shown: 997 filtered tcp ports (no-response). What does this suggest?

    No response usually means a firewall dropped the packets, unlike closed ports that actively reset.
  4. 4. Which part of the output proves the host passed host discovery?

    The line 'Host is up' shows at least one discovery probe got an answer; only then are ports scanned.

Summary

  • nmap target scans the 1,000 most common TCP ports after a host-discovery step.
  • The report shows host status, a grouped summary of uninteresting ports and a table of PORT, STATE and SERVICE.
  • Service names are guesses from port numbers; reasons in parentheses explain how states were decided.
  • Practice on localhost or machines you own.
  • Comparing scans over time (set differences) is a simple and powerful habit.

Next: Specifying Targets