Nmap usage

-WORK-IN-PROGRESS-

Intro

Nmap is probably one of the most useful tools I’ve used ever. Yeah - I’m going all fanboy on it but it is really hard to describe it with any less enthusiasm. Basically Nmap is a network scanning tool. It scan hosts and ports - that’s it. But the sheer amount of data it can gather and the flexibility of the tool itself makes it really stand out.

So who would benefit from knowing Nmap? Well, sysadmins, for one. You’ve just set up a new server. The service seems fine, but somehow you can’t connect to it? A quick Nmap against the service port can show you how other computers see it from the outside.

Pretty much anyone in IT can benefit from knowing basic Nmap: determining if a host is live, if a port is open, or if a service is running on the port. But the main audience? Cybersecurity professionals. You can do a pretty big portion of any enumeration with just Nmap, including vulnerability scanning.

The approach of this article is simple

Installation and usage

Let’s face it: if you can’t even install a program in Linux, this might not be the article for you. But hey, let’s give you the benefit of the doubt.

Once installed, run nmap in your terminal or command prompt. If it doesn’t scream at you, congratulations—you’ve passed the first test.

Intro to networking

Before diving into scans, let’s cover some basics:

Scan types

As Nmap offers a wealth of different scan types let's start off with the most basic host scan. A host scan is a scan where we aim to discover as many hosts (machines) on the network as possible.

A basic Nmap host scan would look something like this:

Terminal
parkado@homelab.hl$ nmap 192.168.0.1/24
Starting Nmap 7.95 ( https://nmap.org ) at 2025-01-04 21:13 CET
Nmap scan report for 192.168.0.1
Host is up (0.014s latency).
Not shown: 996 closed tcp ports (reset)
PORT     STATE SERVICE
53/tcp   open  domain
80/tcp   open  http
443/tcp  open  https
1900/tcp open  upnp
MAC Address: 34:60:F9:D4:05:8C (TP-Link Limited)

Nmap scan report for 192.168.0.16
Host is up (0.016s latency).
Not shown: 997 closed tcp ports (reset)
PORT     STATE SERVICE
22/tcp   open  ssh
111/tcp  open  rpcbind
3128/tcp open  squid-http
MAC Address: B8:85:84:A7:4E:DC (Dell)

Nmap scan report for 192.168.0.27
Host is up (0.0058s latency).
Not shown: 997 filtered tcp ports (no-response)
PORT    STATE  SERVICE
22/tcp  open   ssh
80/tcp  open   http
443/tcp closed https
MAC Address: BC:24:11:7E:86:B3 (Proxmox Server Solutions GmbH)

Nmap scan report for pi.hole (192.168.0.54)
Host is up (0.016s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE
53/tcp open  domain
80/tcp open  http
MAC Address: E4:5F:01:68:1A:B9 (Raspberry Pi Trading)

Nmap done: 256 IP addresses (4 hosts up) scanned in 35.37 seconds

Here we can see that Nmap found 4 machines on the network and scanned each hosts 1000 most popular ports. For each host we have a output that shows what ports were discovered, in what state they are and what service is running on them.

You can also run a scan against a single target using either IP address or their hostname or URL like this:

Terminal
parkado@homelab.hl$ nmap parkado.it
Starting Nmap 7.95 ( https://nmap.org ) at 2025-01-05 14:37 CET
Nmap scan report for parkado.it (188.245.159.79)
Host is up (0.044s latency).
rDNS record for 188.245.159.79: static.79.159.245.188.clients.your-server.de
Not shown: 997 filtered tcp ports (no-response)
PORT    STATE  SERVICE
22/tcp  open   ssh
80/tcp  closed http
443/tcp open   https

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

If you run a basic Nmap scan like this then the default -sS flag is used, when using sudo nmap target then it will use -sT as default. In both cases it will scan TCP ports by default.

Here is a list of other scan types that we can use. Do check out Nmap docs on the Resources section to find out even more.

Nmap scripting engine (NSE)

Nmap’s scripting engine is one the reasons why I think it is the most versatile tool you can learn. With the scripting engine you can use default script or create your own and share them. The scripting part is done in Lua but it really isn't that hard.

Output and reporting

Nmap’s reporting options are ridiculously flexible:

Advanced concepts

Detection and Evasion

Polite scan and minimal disruption

Some systems can’t handle aggressive scans. Use -T2 or -T3 to stay on the safe side.

Scan performance factors

Practical usage

Here’s a real-world example:

Terminal
parkado@homelab.hl$ sudo nmap -sS -sU -sC -p- -oA scan_results 192.168.1.1

This command does:

Conclusion

Nmap is a beast of a tool. Whether you’re troubleshooting a network issue, mapping out your infrastructure, or scanning for vulnerabilities, it’s got your back.

Resources