Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

nmap: analyze network exposure

32 min read
Improve this page

You need to know which services a machine exposes, or check that a firewall really blocks what it should block. nmap, created in 1997 by Gordon Lyon (Fyodor), sends packets to the ports of a machine and classifies each port according to the answer received, or the lack of one.

This page teaches the basic task on a machine of your own: list the ports, read their state, name the services, then compare the result with what should be exposed. To test a single port by hand, see netcat; to watch the packets of a scan go by, tcpdump.

Can you scan without permission?

No, except on your own machines. A scan leaves traces in the target's logs and can trigger its intrusion detection systems. It tests ports that nobody opened for that purpose, which goes beyond the normal use of a service.

Written authorization: the rule of the profession

Scanning a system that is not yours without written authorization goes against professional rules, and may expose you to prosecution: fraudulent access or remaining in a system (article 323-1 of the French Criminal Code), obstruction (article 323-2, an intentional offence). The law does not say where fraud begins for a simple scan: the judge assesses the facts. Use nmap only on your own machines, or on a network for which you hold written authorization. With a cloud provider, also read its policy on security testing.

Every command on this page targets srv, your test server, or localhost. For the distinction between normal use, grey area and written authorization, read the legal framework (in French).

What you will learn

  • List the ports of a machine with -p and read the open, closed and filtered states
  • Name the service and its version with -sV, and hide the ports that are not open with --open
  • Tell a closed port from a filtered port, by the answer and by the duration of the scan
  • Know what sudo changes, find the live machines with -sn and save a scan with -oN
  • Write the expected exposure of a machine and compare it with what nmap observes on all ports
  • Know the risks of NSE scripts and the limits of a UDP scan or of an announced version

Prerequisites

You know how to open a terminal, connect over SSH and read the output of ss -ltn (netcat uses it). As with scp, a server srv reachable with ssh srv is enough. Your account must be able to run sudo on your workstation (for sudo nmap) and sudo nft on srv, and only on that test server. The outputs on this page assume a srv with no firewall rule at the start: otherwise, yours will differ.

Without a server, your own machine can play srv with localhost for the discovery part, but a scan of localhost does not show the real exposure. It goes through the loopback interface: it sees services that no other machine can reach, and most firewalls leave that interface open. The two exercises need a real server.

Install nmap

nmap is installed from the distribution repositories. Then check the version: the outputs on this page come from Nmap 7.95, the Debian 13 version. The upstream version is 7.991, released on 6 August 2026 according to the nmap.org changelog.

Terminal window
sudo apt install nmap # Debian, Ubuntu
sudo dnf install nmap # AlmaLinux, Fedora
nmap -V | head -1
Output
Nmap version 7.95 ( https://nmap.org )

Create the test folder

The examples write their files into ~/nmap-lab, a throwaway folder that the final cleanup deletes. The name srv must resolve through DNS or /etc/hosts: nmap does not read ~/.ssh/config. Otherwise, write the server's IP address in place of srv.

A name that neither DNS nor /etc/hosts knows gives Failed to resolve "inconnu.invalid", the warning WARNING: No targets were specified, then 0 IP addresses (0 hosts up), and nmap exits with code 0. A script that does not read the text believes the scan succeeded.

The outputs come from Nmap 7.95 (Debian 13) talking to an Ubuntu 26.04 server; (IP) stands for the server's address, you will read your own. They are shortened: the Starting Nmap and Nmap done lines are kept only when the text relies on them.

The script service-test.sh serves the exercises: it starts or stops a small web server on srv, in a dedicated folder ~/nmap-srv (never your home directory, which it would publish).

mkdir ~/nmap-lab && cd ~/nmap-lab
cat > service-test.sh <<'EOF'
#!/usr/bin/env bash
PORT=$((41000 + 234))
case "$1" in
start) ssh srv "mkdir -p ~/nmap-srv && echo test > ~/nmap-srv/index.html && (nohup python3 -m http.server $PORT --directory ~/nmap-srv > /dev/null 2>&1 &)" ;;
stop) ssh srv "pkill -f 'http[.]server $PORT'" ;;
esac
EOF
chmod +x service-test.sh

The nmap command in detail

An nmap command is written in this order: the options, then the target. Read the line from left to right: each number points to the explanation of that part.

Anatomy of the command

Syntaxnmap [options] target

  1. nmap the programIt questions machines and their ports.
  2. -sV the versionoptionalQuestions the services of open ports.
  3. --open the filteroptionalDisplays open ports only.
  4. -p 22 the portsoptionalA list, a range, or -p- for all.
  5. srv the targetA name, an address or a network.

Output22/tcp open ssh, and its version

The three states of a port

nmap does not look inside the machine: it asks for a connection on each port and reads what comes back. Three answers are possible, so three states. A port that accepts the connection (SYN-ACK answer) is open. A port that refuses (RST answer) is closed: the machine answered, no service listens. A port that answers nothing is filtered: something, most often a firewall, drops the packets.

A filtered port is not a closed port: the closed port answers, the filtered port stays silent, and an active service may sit behind it. The following sections show each state on srv.

Specify the ports

-p sets the ports to test: a single one (-p 22), a list (-p 22,80,443), a range (-p 1-1024) or all of them (-p-, the 65535). On srv, port 22 (SSH) accepts connections and port 80 has no service:

Terminal window
nmap -p 22,80 srv
Output
Starting Nmap 7.95 ( https://nmap.org ) at 2026-11-25 12:56 UTC
Nmap scan report for srv (IP)
Host is up (0.00017s latency).
PORT STATE SERVICE
22/tcp open ssh
80/tcp closed http
Nmap done: 1 IP address (1 host up) scanned in 0.01 seconds

Look at the STATE column: open for 22, closed for 80. The SERVICE column gives the name that nmap associates with that port number in its internal list, without checking anything. Without -p, nmap tests the 1000 most common ports:

Terminal window
nmap srv
Output
Nmap scan report for srv (IP)
Host is up (0.000071s latency).
Not shown: 999 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh

The line Not shown: 999 closed tcp ports sums up the closed ports instead of listing them. A service listening on a rare port, outside these 1000, therefore goes unnoticed: this is why an exposure audit scans all the ports of a target with -p- (see "Compare the exposure to what is expected"). The -F option does the opposite and tests only the 100 most common ports: it is faster and sees even less.

Read a service version with -sV

-sV sends probes to each open port and compares the answers with a signature database. The result is added in the VERSION column. See also banner grabbing (in French).

Terminal window
nmap -sV -p 22 srv
Output
Nmap scan report for srv (IP)
Host is up (0.00042s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 10.2p1 Ubuntu 2ubuntu3.8 (Ubuntu Linux; protocol 2.0)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .

The line for port 22 names the software and its version, which the scan without -sV did not. -sV applies only to open ports: a closed or filtered port keeps its state without a version, and its service name remains a guess drawn from the port list.

The version comes from what the service answers, and an administrator can change that answer. To confirm a version before concluding that a vulnerability exists, do not re-read the banner: check the package installed on the host, for example with dpkg -s openssh-server on srv.

Keep only open ports with --open

On a machine that closes most of its ports, the closed and filtered lines drown the useful information. --open prints only the open ports. Compare with and without, on the same two ports; grep /tcp keeps only the port lines.

Terminal window
nmap -p 22,80 srv | grep /tcp
nmap --open -p 22,80 srv | grep /tcp
Output
22/tcp open ssh
80/tcp closed http
22/tcp open ssh

The first two lines come from the first scan, the third from the second: the line for port 80 is gone. --open changes the display, not the scan: nmap tested both ports in both cases. The two options combine, for example nmap -sV --open -p 22 srv.

Read a filtered port

To see a filtered port, you need a firewall that drops packets. This nft rule is added on your test server only: it drops TCP packets to port 9999 alone and touches neither SSH nor anything else. It lives in a table named lab-nmap, which the cleanup of the page deletes with a single command. Add -t to ssh so that sudo can ask for a password.

Terminal window
ssh -t srv "sudo nft add table inet lab-nmap && sudo nft add chain inet lab-nmap input '{ type filter hook input priority 0; }' && sudo nft add rule inet lab-nmap input tcp dport 9999 drop && sudo nft list table inet lab-nmap"

With localhost as the server, run the same block directly, without ssh:

Terminal window
sudo nft add table inet lab-nmap
sudo nft add chain inet lab-nmap input '{ type filter hook input priority 0; }'
sudo nft add rule inet lab-nmap input tcp dport 9999 drop
sudo nft list table inet lab-nmap
Output
table inet lab-nmap {
chain input {
type filter hook input priority filter; policy accept;
tcp dport 9999 drop
}
}

The command prints only your table. nft list ruleset, by contrast, shows all the tables of the server, including those that are not yours: do not run it to check your rule alone. drop discards the packet without answering anything, which produces the silence of a filtered port. Now scan the three ports:

Terminal window
nmap -p 22,80,9999 srv
Output
Nmap scan report for srv (IP)
Host is up (0.00039s latency).
PORT STATE SERVICE
22/tcp open ssh
80/tcp closed http
9999/tcp filtered abyss
Nmap done: 1 IP address (1 host up) scanned in 1.22 seconds

Read two things. Port 9999 is filtered. And the scan took 1.22 s, against 0.01 s for the two ports of the previous scan: nmap waits for an answer that never comes, then retries, before concluding. A closed port answers right away, a filtered port slows the scan down. The name abyss comes from nmap's port list, not from an observation: nobody was queried.

Read open, closed and filtered with --reason

--reason adds the evidence for the verdict to each port. An open port gives syn-ack, a closed port conn-refused (Connect scan) or reset (SYN scan), a port filtered by drop gives no-response.

Terminal window
nmap --reason -p 22,80,9999 srv
Output
Nmap scan report for srv (IP)
Host is up, received conn-refused (0.00012s latency).
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack
80/tcp closed http conn-refused
9999/tcp filtered abyss no-response
Nmap done: 1 IP address (1 host up) scanned in 1.22 seconds

drop is not the only way to filter. Tested on srv with nmap --reason -p 9999 srv, two reject rules answer instead of staying silent:

Rule on srvState displayedEvidenceScan duration
dropfilteredno-response0.21 s
reject with icmpx type admin-prohibitedfilteredhost-unreach without sudo, admin-prohibited with sudo0.01 s
reject with tcp resetclosedconn-refused0.01 s

A fast answer therefore does not prove that no filter exists: a reject with tcp reset imitates a closed port, and nmap displays closed. Only ss -ltn run on the target says whether a service listens. To close what must not be exposed, see firewalld.

How nmap judges a port, step by step

Predict before you look at the map, for nmap -p 22,80,9999 srv with the drop rule you have just added on srv. Which states does nmap give to the three ports? How many port lines remain displayed with --open? And what does -sV change on the line of port 22, and on that of port 9999? Then check: tick -sV then --open in the options, and follow the scan port by port.

Mental model

How nmap judges a port

try to connectread the answergive the port a state for each requested port

$ nmap -p 22,80,9999 srv | grep /tcp

  1. Port 22 accepts the connection: it is open.
  2. Port 80 refuses: nothing listens, it is closed. The machine itself did answer.
  3. Port 9999 does not answer at all: a firewall drops the packets. It is filtered, and nmap has to wait.
  4. 3 lines displayed.

What the animation shows

  1. Three answers, three states: accepted open, refused closed, silence filtered.
  2. Closed is not filtered: a closed port answers, a filtered port stays silent.
  3. The service name is assumed from the port number, except with -sV.
  4. A silence slows the scan down: nmap waits before concluding.

Golden rules

Scan with a written authorization

Your machines, or those entrusted to you:

nmap -p 22,80 srv

Limit the ports

Shorter, and less visible in the logs:

nmap -p 22 srv

Essential vocabulary

Choose · which ports

-p 22,80
Two specific portsnmap -p 22,80 srv | grep /tcp → open, closed
-p 22
One open portnmap -p 22 srv | grep /tcp → open
nmap srv
The thousand common portsnmap srv | grep /tcp → 22 open, 9999 filtered
--open
Open ports onlynmap --open -p 22,80 srv | grep /tcp → one line

Interpret · what the answer says

-sV
The version of the servicenmap -sV -p 22 srv | grep /tcp → OpenSSH 10.2p1
closed
A closed portnmap -p 80 srv | grep /tcp → closed
filtered
A filtered portnmap -p 9999 srv | grep /tcp → filtered
-sS
A scan that needs rootnmap -sS -p 22 srv → refused without sudo
A service that nmap cannot see Exercise 1 of 2 · ~8 min · terminal

A colleague tells you that port 9999 of srv is "protected by the firewall". The drop rule from the section "Read a filtered port" is in place. You start a small web server on that port and look for what nmap says about it, then what srv says about it.

Start a service on port 9999 of srv

Start a test web server in the dedicated folder ~/nmap-srv, in the background.

Terminal window
ssh srv "mkdir -p ~/nmap-srv && (nohup python3 -m http.server 9999 --directory ~/nmap-srv > /dev/null 2>&1 &)"

Compare the scan and srv

Scan only port 9999 of srv and read the state. Then, on srv, list the listening TCP ports and keep the line for port 9999.

Conclude

Compare the two results. Say what the scan proves and what it does not prove about that port.

A hint 1 / 1

nmap looks from the outside, ss from inside the machine.

I have tried: show the solution
Terminal window
nmap -p 9999 srv
ssh srv "ss -ltn | grep 9999"
Output
PORT STATE SERVICE
9999/tcp filtered abyss
LISTEN 0 5 0.0.0.0:9999 0.0.0.0:*

The scan gives filtered in 0.21 s, and ss shows LISTEN: a service really does listen. The rule drops the packets before they reach it, so nmap cannot see it. filtered does not prove that no service listens, it only proves that a filter sits between you and the port.

Find the machines: -sn and -Pn

Before scanning the ports, nmap checks that the machine answers. -sn stops at that step: it says whether the machine is alive, without scanning any port.

Terminal window
nmap -sn srv
Output
Nmap scan report for srv (IP)
Host is up (0.00048s latency).

Without sudo, nmap tests the machine with TCP connections on ports 80 and 443. With sudo, it queries over ARP on a local network, which is more reliable, and it prints the target's MAC address: the line MAC Address: 00:16:3E:CD:00:12 (Xensource) appears only with sudo nmap -sn srv.

To discover the machines of a network, replace srv with your network, which you are allowed to scan: nmap -sn -n <your-authorized-network>. The -n option removes the DNS resolution of addresses, which slows the sweep down when the DNS server is slow to answer.

First discover the live machines with -sn, then scan the ports of those machines only: testing all the ports of all possible addresses costs many more packets.

The -Pn option does the opposite of -sn: it skips the check and assumes the machine is alive. It is useful when nmap answers Host seems down although the machine is running, because a firewall blocks discovery. Here is the difference on an address that does not answer, 192.0.2.1, reserved for documentation:

Terminal window
nmap -sn 192.0.2.1 | tail -2
nmap -Pn -p 22 192.0.2.1 | grep -E 'Host|/tcp|done'
Output
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 3.00 seconds
Host is up.
22/tcp filtered ssh
Nmap done: 1 IP address (1 host up) scanned in 2.04 seconds

With -Pn, nmap prints Host is up without having received any answer, then tests the port. On a machine that is switched off, you have to wait for the timeouts of each port: on a large network, -Pn makes the scan much longer.

With or without sudo

Without sudo, nmap opens real TCP connections, which is called a TCP Connect scan (-sT). With sudo, it builds its own packets, and then chooses the SYN scan (-sS). An explicit -sS without sudo is refused:

Terminal window
nmap -sS -p 22,80 srv
Output
You requested a scan type which requires root privileges.
QUITTING!

SYN scan vs TCP Connect

The SYN scan sends the first packet of the connection, reads the answer and cuts off with an RST: the connection is never established and the application does not see it in its logs. The Connect scan goes all the way through the handshake, and the service keeps a trace of it. Firewalls and detection systems spot both.

To build its packets, nmap needs access to raw sockets (raw sockets), reserved for root, hence sudo. With sudo nmap -sS -p 22,80 srv, the states are the same (open for 22, closed for 80). The only addition is the line MAC Address: 00:16:3E:CD:00:12 (Xensource), read over ARP: it appears only on the same local network as the target.

Which scan type does nmap choose without telling you?

The pitfall is the default scan: it changes type when you go from nmap to sudo nmap, and a report that announces a "half-open scan" may be wrong. nmap -v names the type used in the Initiating … Scan line.

Terminal window
nmap -v -n -p 22 srv | grep Initiating
sudo nmap -v -n -p 22 srv | grep Initiating
Output
Initiating Ping Scan at 14:33
Initiating Connect Scan at 14:33
Initiating ARP Ping Scan at 14:33
Initiating SYN Stealth Scan at 14:33

The first two lines come from the scan without sudo (Connect Scan), the next two from the scan with sudo (SYN Stealth Scan, preceded by an ARP Ping Scan). To pin the type down in a report, name it: nmap -sT without privileges, sudo nmap -sS with them.

Export the results

Without an export, a scan exists only in the terminal, which prevents comparing it with the next scan. -oN writes the readable report to a file; -oX writes XML for analysis tools, -oG one line per host for scripts, and -oA all the formats at once with the same prefix.

Terminal window
nmap -oN scan.txt -p 22,80 srv > /dev/null; cat scan.txt
Output
# Nmap 7.95 scan initiated Wed Nov 25 14:33:53 2026 as: nmap -oN scan.txt -p 22,80 srv
Nmap scan report for srv (IP)
Host is up (0.00030s latency).
PORT STATE SERVICE
22/tcp open ssh
80/tcp closed http
# Nmap done at Wed Nov 25 14:33:53 2026 -- 1 IP address (1 host up) scanned in 0.03 seconds

The file keeps the report and the command line that produced it. Keep it: compared with the next scan, it shows what changed, and each difference needs an explanation.

Compare the exposure to what is expected

A scan is not an audit. The audit begins when you write down, before scanning, the list of ports that must be open, then compare it with what nmap observes. A gap is either a forgotten service or wrong documentation.

Write the expected, extract the observed, compare

The expected is a decision, not a measurement: it comes from the server's documentation. Here, srv must expose only SSH. The observed comes from a scan of all the ports (-p-): the default scan looks at only 1000 ports and would let a service on a rare port slip through. grep keeps the port lines, tr -s ' ' squeezes multiple spaces into one, and diff compares the two files.

Terminal window
printf '22/tcp open ssh\n' > attendu.txt
nmap -p- srv | grep /tcp | tr -s ' ' > constate.txt
diff attendu.txt constate.txt && echo "exposition conforme"
Output
1a2
> 9999/tcp filtered abyss

A line prefixed with > flags an observed port that was not planned, a line prefixed with < an expected port that does not answer, so a failure or outdated documentation. Here the gap is port 9999: it is the firewall rule added above. A scan of all the ports took less than 2 seconds on srv, on a local network.

To fix a gap, you remove the service or you complete the expected list if the documentation was wrong. The fix is proved by replaying exactly the same scan: the gap disappears, and diff prints nothing.

The port the default scan does not see Exercise 2 of 2 · ~10 min · terminal

A colleague started a service on srv without documenting it. You keep the attendu.txt file from the previous section, which plans only SSH, and you compare two kinds of scan to find the service.

Start the service

Run the script from the test folder. It starts the service on a port that you have to discover: do not read it.

Terminal window
./service-test.sh start

Compare two scans

Redo the observed list with nmap srv (without -p-), run diff attendu.txt constate.txt and count the > lines. Start again with nmap -p- srv and note the new port.

Stop the service and replay the scan

Stop the service with ./service-test.sh stop, then replay the scan of all ports and the diff.

A hint 1 / 2

The default scan tests only the 1000 most common ports.

A hint 2 / 2

Look for the line that changes between the two diff runs, not the one for 9999.

I have tried: show the solution
Terminal window
nmap srv | grep /tcp | tr -s ' ' > constate.txt; diff attendu.txt constate.txt
nmap -p- srv | grep /tcp | tr -s ' ' > constate.txt; diff attendu.txt constate.txt
./service-test.sh stop
nmap -p- srv | grep /tcp | tr -s ' ' > constate.txt; diff attendu.txt constate.txt
Output
1a2
> 9999/tcp filtered abyss
1a2,3
> 9999/tcp filtered abyss
> 41234/tcp open unknown
1a2
> 9999/tcp filtered abyss

The default scan sees only 9999: it wrongly concludes that everything is compliant, apart from that one. The scan of all the ports adds 41234/tcp open unknown, a service that nobody had documented. After the stop, only 9999 remains. An audit that stops at the default scan therefore misses any service on a rare port.

Options that cost a lot

These options add information, and noise: more packets, so more traces on the target.

Advanced detection

-O guesses the operating system from the target's TCP/IP fingerprint. The result is a probability, and -O requires sudo rights as well as at least one open port and one closed port to compare their answers. Without sudo, nmap -O srv stops on TCP/IP fingerprinting (for OS scan) requires root privileges. With sudo, the scan took 12.6 s on srv, and nmap found no exact match (No exact OS matches for host): it then prints the fingerprint without naming the system.

-A adds nothing new: it enables -sV, -O, the default scripts and the traceroute all at once, which makes it easy for a detection system to spot. Start with a light scan.

Speed control

-T0 to -T5 set the delays and the number of probes sent in parallel. -T3 is the default value, -T4 suits a reliable internal network, and -T5 risks missing ports: a port whose answer arrives after the delay is counted as filtered, with no error displayed.

NSE scripts

The Nmap Scripting Engine (NSE) runs scripts written in Lua, shipped with the tool. A script queries the discovered service, tests a configuration or checks a known vulnerability. Their level of intrusion varies a lot from one script to the next: read the category before running.

Script categories

Each script belongs to one or more categories. auth and vuln send real test requests to the services and can disturb them. brute, exploit, intrusive, fuzzer and dos change the state of the target or can interrupt it: they belong on a system you own, never on a production system. The default category, run by -sC, mixes safe scripts with others classified as more intrusive: do not consider it harmless.

Using scripts

-sC runs the scripts of the default category. --script accepts a script name, a category or a pattern.

Never run a broad pattern such as http-*: it includes dangerous scripts. First list what it contains with --script-help, which prints the documentation without scanning anything, adding and safe. Put the pattern between quotes, otherwise the shell replaces the star with file names before nmap receives it.

Terminal window
nmap -sC -p 22 srv
nmap --script=banner -p 22 srv
nmap --script-help 'http-* and safe' | grep -c '^http-'
Output
22/tcp open ssh
22/tcp open ssh
|_banner: SSH-2.0-OpenSSH_10.2p1 Ubuntu-2ubuntu3.8
64

The first scan, -sC -p 22, prints no script result on that port: the absence of output does not say that the service is safe, only that the default scripts have nothing to say here. The second runs a single script, banner, which reads what the service announces. The last command counts 64 http-* scripts classified safe in version 7.95.

Scan UDP: why so slow?

UDP sends no acknowledgement. A closed port answers with an ICMP error message, but the target limits the rate of these answers: nmap has to slow down and retry, and a scan of 1000 UDP ports becomes very long. An open port often stays silent, and the port is then shown as open|filtered: nmap cannot tell a silent service from a firewall that drops the packet. So target the common UDP ports, with sudo:

Terminal window
time sudo nmap -sU -p 53,67,161 srv
Output
PORT STATE SERVICE
53/udp closed domain
67/udp closed dhcps
161/udp closed snmp
MAC Address: 00:16:3E:CD:00:12 (Xensource)
Nmap done: 1 IP address (1 host up) scanned in 0.19 seconds

Here the three ports are closed and the scan took 0.2 s, because srv answers with an ICMP message for each of them.

Troubleshooting

Start by replaying the scan with --reason, which prints the answer received for each port. Then compare with ss -ltn on the target, which says what really listens.

SymptomCauseSolution
You requested a scan type which requires root privileges-sS, -O or -sU without sudoAdd sudo, or use -sT
Host seems downFirewall blocking discovery, host switched off, wrong addressCheck the address, then -Pn
Failed to resolve and 0 hosts, code 0Name unknown to DNS and /etc/hostsWrite the IP address
All 1000 scanned ports are filteredStrict firewall, protected host, wrong networkCheck the network path, --reason
A very long scanToo many ports, UDP scan, DNS resolutionReduce -p, target UDP, add -n
A wrong service name, for example abyssThe name comes from the port listAdd -sV

Clean up the test folder

Remove the nft table (a single removal for the whole page), stop the test web servers, then delete the test folders. Re-read the names before running rm -r.

Terminal window
ssh -t srv "sudo nft delete table inet lab-nmap"
ssh srv "pkill -f 'http[.]server 9999'; rm -r ~/nmap-srv"
cd ~
rm -r ~/nmap-lab

For localhost, remove the table with sudo nft delete table inet lab-nmap, without ssh.

Key points

  • Three answers, three states: connection accepted open, refused closed, no answer filtered. A filtered port is not closed, and a service may listen behind it.
  • Without -p, nmap tests the 1000 most common ports; an exposure audit scans all 65535 with -p-.
  • The service name comes from a port list, except with -sV, which compares probes with signatures and applies only to open ports.
  • Without sudo, the scan is of the Connect type; with sudo, of the SYN type, with the MAC address in addition. Name the type in a report.
  • An audit is a comparison: write the expected list first, scan all ports, compare with diff, fix, replay the same scan.
  • A UDP scan is slow and open|filtered proves nothing; NSE scripts of the intrusive categories run only on your own machines.

Knowledge check

Check that the essentials of this guide stuck. The questions cover only what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

10 questions
8 min
80% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer

FAQ: frequently asked questions