Nmap

6 min read1,012 words

NMap

1. Install Nmap

Kali Linux

sudo apt update sudo apt install nmap -y

Check:

nmap --version

2. Basic Scanning

Scan one IP

nmap 192.168.1.10

Scan a hostname

nmap example.com

Scan multiple IPs

nmap 192.168.1.10 192.168.1.20

Scan a range

nmap 192.168.1.1-50

Scan an entire subnet

nmap 192.168.1.0/24

3. Host Discovery

Find which machines are online without doing a port scan:

nmap -sn 192.168.1.0/24

This is particularly useful in your own home/lab network.

Disable ping discovery

nmap -Pn 192.168.1.10

Useful when the target blocks ICMP discovery.

4. Port Scanning

Common ports

nmap 192.168.1.10

Specific port

nmap -p 22 192.168.1.10

Multiple ports

nmap -p 22,80,443 192.168.1.10

Port range

nmap -p 1-1000 192.168.1.10

All TCP ports

nmap -p- 192.168.1.10

This scans ports 1–65535.

Top 100 ports

nmap --top-ports 100 192.168.1.10

5. TCP Scan Types

SYN scan

sudo nmap -sS 192.168.1.10

Commonly used during authorized security assessments.

TCP connect scan

nmap -sT 192.168.1.10

Useful when raw packet privileges aren't available.

UDP scan

sudo nmap -sU 192.168.1.10

Specific UDP ports:

sudo nmap -sU -p 53,67,68,123,161 192.168.1.10

UDP scans can be considerably slower.

6. Service Detection

Finding an open port is only the beginning.

nmap -sV 192.168.1.10

Example:

PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 80/tcp open http Apache 3306/tcp open mysql MySQL

Increase service detection intensity

nmap -sV --version-intensity 9 192.168.1.10

7. OS Detection

sudo nmap -O 192.168.1.10

Combine OS and service detection:

sudo nmap -O -sV 192.168.1.10

8. Aggressive Scan

Nmap's -A enables several detection features together:

sudo nmap -A 192.168.1.10

It includes things such as:

  • OS detection
  • Version detection
  • Script scanning
  • Traceroute

A more controlled alternative is to explicitly select the features you need:

sudo nmap -O -sV --traceroute 192.168.1.10

9. Nmap NSE Scripts

Nmap has a scripting engine called NSE — Nmap Scripting Engine.

List available scripts:

ls /usr/share/nmap/scripts/

Search for scripts:

ls /usr/share/nmap/scripts/ | grep http

Run a specific script

For example, against a lab web server:

nmap --script=http-title 192.168.1.10

HTTP headers

nmap --script=http-headers -p80,443 192.168.1.10

SSH information

nmap --script=ssh2-enum-algos -p22 192.168.1.10

SMB information

nmap --script=smb-os-discovery -p445 192.168.1.10

10. Vulnerability-Checking Scripts

Nmap includes NSE scripts categorized for vulnerability assessment.

You can inspect the available vulnerability scripts:

ls /usr/share/nmap/scripts/ | grep vuln

For an authorized lab target, you can run the vulnerability category:

sudo nmap --script vuln 192.168.1.10

Don't blindly run this against Internet systems you don't own or have permission to assess.

11. Web Enumeration

For a web server:

nmap -p80,443 -sV 192.168.1.10

HTTP title:

nmap --script=http-title -p80,443 192.168.1.10

HTTP methods:

nmap --script=http-methods -p80,443 192.168.1.10

HTTP headers:

nmap --script=http-headers -p80,443 192.168.1.10

12. SMB Enumeration

For your own Windows/Metasploitable lab:

nmap -p445 --script=smb-os-discovery 192.168.1.10

Check SMB protocols:

nmap -p445 --script=smb-protocols 192.168.1.10

SMB security mode:

nmap -p445 --script=smb-security-mode 192.168.1.10

13. DNS Enumeration

DNS version:

nmap -sV -p53 192.168.1.10

DNS service scripts:

nmap --script=dns-* -p53 192.168.1.10

For a controlled DNS server, you can investigate supported DNS functionality using the relevant NSE scripts.

14. FTP Enumeration

nmap -p21 -sV 192.168.1.10

FTP anonymous-access check:

nmap --script=ftp-anon -p21 192.168.1.10

FTP banner:

nmap --script=ftp-syst -p21 192.168.1.10

15. SSH Enumeration

nmap -p22 -sV 192.168.1.10

SSH algorithms:

nmap --script=ssh2-enum-algos -p22 192.168.1.10

SSH host keys:

nmap --script=ssh-hostkey -p22 192.168.1.10

16. MySQL Enumeration

nmap -p3306 -sV 192.168.1.10

MySQL information:

nmap --script=mysql-info -p3306 192.168.1.10

17. Save Results

Normal output

nmap -oN scan.txt 192.168.1.10

XML

nmap -oX scan.xml 192.168.1.10

Grepable output

nmap -oG scan.txt 192.168.1.10

All major formats

nmap -oA scan_results 192.168.1.10

Creates:

scan_results.nmap scan_results.xml scan_results.gnmap

18. Timing

Nmap has timing templates:

-T0 -T1 -T2 -T3 -T4 -T5

Example:

sudo nmap -T4 192.168.1.10

For a normal authorized lab, -T4 is commonly convenient.

19. Useful Practical Combinations

Quick discovery

nmap -sn 192.168.1.0/24

All ports

sudo nmap -p- 192.168.1.10

All ports + service versions

sudo nmap -p- -sV 192.168.1.10

Common practical assessment scan

sudo nmap -sS -sV -O 192.168.1.10

Detailed lab scan

sudo nmap -p- -sV -O --script=default 192.168.1.10

Save detailed results

sudo nmap -p- -sV -O -oA assessment 192.168.1.10

20. A Real Ethical-Hacking Workflow

Instead of randomly running commands, learn Nmap as an assessment workflow:

1. Identify target ↓ 2. Host discovery ↓ 3. Port discovery ↓ 4. Service detection ↓ 5. OS detection ↓ 6. NSE enumeration ↓ 7. Vulnerability assessment ↓ 8. Document findings

For example, in a Metasploitable2 lab:

nmap -sn 192.168.56.0/24

Suppose your lab target is:

192.168.56.101

Then:

nmap -p- 192.168.56.101

Follow up with:

nmap -sV -p- 192.168.56.101

Then:

sudo nmap -O 192.168.56.101

Then investigate individual services:

nmap --script=http-title -p80 192.168.56.101
nmap --script=ftp-anon -p21 192.168.56.101
nmap --script=smb-os-discovery -p445 192.168.56.101

Finally save your assessment:

sudo nmap -sV -O -oA metasploitable-assessment 192.168.56.101

The important skill

Don't try to memorize 100 Nmap commands. Learn to interpret:

Port → Service → Version → Configuration → Potential weakness → Verification

For example:

22/tcp open SSH 80/tcp open HTTP 139/tcp open NetBIOS 445/tcp open SMB 3306/tcp open MySQL

Each open service becomes a separate area for authorized enumeration and security testing.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy