UnixDroid

Lesson 5 of 5 · 9 min

Your first Nmap scan

Find the open ports and the software behind them on your lab target, and learn to read every line of the result.

Nmap (Network Mapper) is the most widely used scanning tool in security, and it comes installed on Kali. It answers three questions about a machine: is it online, which ports are open, and what software is running behind them.

Run every command in this lesson against your own lab only. Scanning networks you don't own, or don't have written permission to test, can be illegal. The Nmap project's own scanme.nmap.org allows light test scans.

Reading the command

Every Nmap command has the same shape: the tool, some options, and a target.

An Nmap command split into its five parts: sudo, nmap, -sV, -p 1-1000 and the target IP
An Nmap command split into its five parts: sudo, nmap, -sV, -p 1-1000 and the target IP

Step 1: Find your target

Start Kali and Metasploitable. In Kali, list every live machine on the lab network:

sudo nmap -sn 192.168.56.0/24

-sn means "find hosts, but don't scan ports". You'll see a few addresses: usually your host (.1), Kali, Metasploitable, and sometimes the VirtualBox DHCP server.

Step 2: A basic scan

sudo nmap 192.168.56.102

With no options, Nmap checks the 1,000 most common TCP ports. Metasploitable will give you a long list. Here's part of it:

PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
23/tcp   open  telnet
25/tcp   open  smtp
80/tcp   open  http
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
3306/tcp open  mysql

The SERVICE column here is only a guess based on the port number. We'll fix that in step 4.

Step 3: Open, closed and filtered

When you use sudo, Nmap's default is a SYN scan. It sends the first packet of a TCP handshake and judges the port by the reply.

How Nmap labels a port open, closed or filtered from the reply to a SYN packet
How Nmap labels a port open, closed or filtered from the reply to a SYN packet
StateWhat it means
openA program is listening and accepting connections
closedThe machine is reachable, but nothing listens on that port
filteredA firewall blocked the probe, so Nmap can't tell

Without sudo, Nmap can't send these raw packets, so it falls back to a full connect scan (-sT). It still works, but it's slower and more likely to be logged.

Step 4: Find the real software versions

Version detection makes Nmap talk to each open port and identify what is really running:

sudo nmap -sV -p 21,22,80 192.168.56.102
PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 2.3.4
22/tcp open  ssh     OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
80/tcp open  http    Apache httpd 2.2.8 ((Ubuntu) DAV/2)

Now you have something to research. Search for "vsftpd 2.3.4" and you'll find that this exact version was once distributed with a backdoor hidden inside it. This is how testers move from scanning to the next phase: get the exact version, then research it.

Step 5: Save your results

Always save scans, so you have them for your notes and your report:

sudo nmap -sV -oN lab-scan.txt 192.168.56.102

-oN saves normal text output. -oA lab-scan saves three formats at once.

Options worth remembering

OptionWhat it does
-snFind live hosts, no port scan
-p 80,443Scan only these ports
-p-Scan all 65,535 ports
-sVDetect service versions
-OGuess the operating system
-AVersions, OS, default scripts and traceroute together
-T4Faster timing, fine for labs
-oN file.txtSave the output to a file

On real client networks, start gentle. Loud options like -A or -T5 can slow down, or even crash, fragile devices such as old printers.

Want to go deeper into what those port numbers mean? Read our guide to ports and protocols.

Try it yourself
  1. Run sudo nmap -sn 192.168.56.0/24 and find your target's IP.
  2. Scan every port: sudo nmap -p- 192.168.56.102. How many open ports did you find?
  3. Run -sV on those open ports and save the result with -oN.
  4. Pick two services from your result, search their version numbers online, and write one line about what you find.

Quick check

Which Nmap option detects the software version on each open port?

Need a hint?

s for service, V for version.

Finished this lesson?

Done lessons keep your daily streak going 🔥

0 day streak

0 lessons done

best 0 days

Log in to keep your streak on every device →