From aldeid
Jump to: navigation, search
This article is also available in one or more other languages
To view this article in French, click here
You might also see: Zenmap, Nmap's graphical frontend


Nmap is certainly THE scanner to know. Thanks to its numerous parameters, it is a swiss army knife to all situations where network identification is needed. It enables among other things to list network hosts and scan their ports.


From the package

This method shows how to install Nmap-5.00 from packages. Simply run:

$ sudo apt-get install nmap

From sources

First install development sources of libpcap:

$ sudo apt-get install libpcap-dev

Installing Nmap from sources enables, among other things, to obtain the last development revision (5.35-DC1).

$ cd /data/src/
$ wget http://nmap.org/dist/nmap-5.35DC1.tar.bz2
$ bzip2 -cd nmap-5.35DC1.tar.bz2 | tar xf -
$ cd nmap-5.35DC1/
$ .configure
$ make
$ sudo make install

Without change in the configuration options, Nmap installs in /usr/local/bin/nmap.


Basic syntax

$ ./nmap [Scan Type(s)] [Options] {target specification}


Target Specification

-iL <inputfilename>
Input from list of hosts/networks
-iR <num hosts>
Choose random targets
--exclude <host1[,host2][,host3],...>
Exclude hosts/networks
--excludefile <exclude_file>
Exclude list from file

Host Discovery

List Scan - simply list targets to scan
Ping Scan - disable port scan
Treat all hosts as online -- skip host discovery
TCP SYN/ACK, UDP or SCTP discovery to given ports
ICMP echo, timestamp, and netmask request discovery probes
-PO[protocol list]
IP Protocol Ping
Never do DNS resolution/Always resolve [default: sometimes]
--dns-servers <serv1[,serv2],...>
Specify custom DNS servers
Use OS's DNS resolver
Trace hop path to each host

Scan techniques

TCP SYN/Connect()/ACK/Window/Maimon scans
UDP Scan
TCP Null, FIN, and Xmas scans
--scanflags <flags>
Customize TCP scan flags
-sI <zombie host[:probeport]>
Idle scan
IP protocol scan
-b <FTP relay host>
FTP bounce scan

Port Specification and Scan Order

-p <port ranges>
Only scan specified ports
Ex: -p22 | -p1-65535 | -p U:53,111,137,T:21-25,80,139,8080,S:9
Fast mode - Scan fewer ports than the default scan
Scan ports consecutively - don't randomize
--top-ports <number>
Scan <number> most common ports
--port-ratio <ratio>
Scan ports more common than <ratio>

Service/Version Detection

Probe open ports to determine service/version info
--version-intensity <level>
Set from 0 (light) to 9 (try all probes)
Limit to most likely probes (intensity 2)
Try every single probe (intensity 9)
Show detailed version scan activity (for debugging)

Script Scan

equivalent to --script=default
--script=<Lua scripts>
<Lua scripts> is a comma separated list of directories, script-files or script-categories
provide arguments to scripts
Show all data sent and received
Update the script database.

OS Detection

Enable OS detection
Limit OS detection to promising targets
Guess OS more aggressively

Timing and Performance

Options which take
Set timing template (higher is faster)
--min-hostgroup/max-hostgroup <size>
Parallel host scan group sizes
--min-parallelism/max-parallelism <numprobes>
Probe parallelization
Specifies probe round trip time.
--max-retries <tries>
Caps number of port scan probe retransmissions.
Give up on target after this long
Adjust delay between probes
--min-rate <number>
Send packets no slower than <number> per second
--max-rate <number>
Send packets no faster than <number> per second

Firewall/IDS Evasion and Spoofing

-f; --mtu <val>
fragment packets (optionally w/given MTU)
-D <decoy1,decoy2[,ME],...>
Cloak a scan with decoys
-S <IP_Address>
Spoof source address
-e <iface>
Use specified interface
-g/--source-port <portnum>
Use given port number
--data-length <num>
Append random data to sent packets
--ip-options <options>
Send packets with specified ip options
--ttl <val>
Set IP time-to-live field
--spoof-mac <mac address/prefix/vendor name>
Spoof your MAC address
Send packets with a bogus TCP/UDP/SCTP checksum
Use deprecated Adler32 instead of CRC32C for SCTP checksums


-oN/-oX/-oS/-oG <file>
Output scan in normal, XML, s|<rIpt kIddi3, and Grepable format, respectively, to the given filename.
-oA <basename>
Output in the three major formats at once
Increase verbosity level (use -vv or more for greater effect)
Increase debugging level (use -dd or more for greater effect)
Display the reason a port is in a particular state
Only show open (or possibly open) ports
Show all packets sent and received
Print host interfaces and routes (for debugging)
Log errors/warnings to the normal-format output file
Append to rather than clobber specified output files
--resume <filename>
Resume an aborted scan
--stylesheet <path/URL>
XSL stylesheet to transform XML output to HTML
Reference stylesheet from Nmap.Org for more portable XML
Prevent associating of XSL stylesheet w/XML output


Enable IPv6 scanning
Enables OS detection and Version detection, Script scanning and Traceroute
--datadir <dirname>
Specify custom Nmap data file location
Send using raw ethernet frames or IP packets
Assume that the user is fully privileged
Assume the user lacks raw socket privileges
Print version number
Print this help summary page.


List hosts on a network

$ ./nmap -sP
Starting Nmap 5.35DC1 ( http://nmap.org ) at 2010-11-28 11:20 CET
Nmap scan report for
Host is up (0.0045s latency).
Nmap scan report for
Host is up (0.023s latency).
Nmap scan report for
Host is up (0.000096s latency).
Nmap scan report for
Host is up (0.0097s latency).
Nmap scan report for
Host is up (0.022s latency).
Nmap done: 256 IP addresses (5 hosts up) scanned in 2.59 seconds

Scan a host

This example uses a TCP/SYN scan and tries to identify installed services:

$ sudo ./nmap -sS -sV
Starting Nmap 5.35DC1 ( http://nmap.org ) at 2010-11-28 11:22 CET
Nmap scan report for
Host is up (0.0000060s latency).
Not shown: 997 closed ports
21/tcp open  ftp     vsftpd 2.2.2
22/tcp open  ssh     OpenSSH 5.3p1 Debian 3ubuntu4 (protocol 2.0)
80/tcp open  http    Apache httpd 2.2.14 ((Ubuntu))
Service Info: OSs: Unix, Linux
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.40 seconds
Notice that TCP/SYN scan requires root privileges.