Nmap Cheat Sheet 2024: All the Commands, Flags & Switches (2024)

The one downside to a tool as robust and powerful as Nmap is remembering so many commands. Even many seasoned industry professionals fail to make the most of Nmap simply because keeping track of all its flags can prove such a challenge.

We have compiled and organized this Nmap cheat sheet to help you master what is arguably the most useful tool in any penetration tester’s arsenal. Whether you use it to memorize Nmap’s options, as a quick reference to keep nearby, or as a study sheet for your CEH/Pentest+ exam, we’re certain it will help you become a Nmap pro.

Download your own copy of this cheat sheet here. Now, let’s get to the Nmap commands.

Nmap Cheat Sheet Search

Search our Nmap cheat sheet to find the right cheat for the term you're looking for. Simply enter the term in the search bar and you'll receive the matching cheats available.

Table Of Contents

  1. Nmap Cheat Sheet Search
  2. Target Specification
  3. Nmap Scan Techniques
  4. Host Discovery
  5. Nmap Command Generator
  6. Port Specification
  7. Service and Version Detection
  8. OS Detection
  9. Timing and Performance
  10. Timing and Performance Switches
  11. NSE Scripts
  12. Useful NSE Script Examples
  13. Firewall / IDS Evasion and Spoofing
  14. Output
  15. Helpful Nmap Output examples
  16. Miscellaneous Nmap Flags
  17. Other Useful Nmap Commands
  18. Frequently Asked Questions

Target Specification

SWITCHEXAMPLEDESCRIPTION
nmap 192.168.1.1Scan a single IP
nmap 192.168.1.1 192.168.2.1Scan specific IPs
nmap 192.168.1.1-254Scan a range
nmap scanme.nmap.orgScan a domain
nmap 192.168.1.0/24Scan using CIDR notation
-iLnmap -iL targets.txtScan targets from a file
-iRnmap -iR 100Scan 100 random hosts
-excludenmap -exclude 192.168.1.1Exclude listed hosts

Nmap Scan Techniques

SWITCHEXAMPLEDESCRIPTION
-sSnmap 192.168.1.1 -sSTCP SYN port scan (Default)
-sTnmap 192.168.1.1 -sTTCP connect port scan (Default without root privilege)
-sUnmap 192.168.1.1 -sUUDP port scan
-sAnmap 192.168.1.1 -sATCP ACK port scan
-sWnmap 192.168.1.1 -sWTCP Window port scan
-sMnmap 192.168.1.1 -sMTCP Maimon port scan

Host Discovery

SWITCHEXAMPLEDESCRIPTION
-sLnmap 192.168.1.1-3 -sLNo Scan. List targets only
-snnmap 192.168.1.1/24 -snDisable port scanning. Host discovery only.
-Pnnmap 192.168.1.1-5 -PnDisable host discovery. Port scan only.
-PSnmap 192.168.1.1-5 -PS22-25,80TCP SYN discovery on port x.
Port 80 by default
-PAnmap 192.168.1.1-5 -PA22-25,80TCP ACK discovery on port x.
Port 80 by default
-PUnmap 192.168.1.1-5 -PU53UDP discovery on port x.
Port 40125 by default
-PRnmap 192.168.1.1-1/24 -PRARP discovery on local network
-nnmap 192.168.1.1 -nNever do DNS resolution

Nmap Command Generator

Say goodbye to the hassle of trying to remember the exact syntax for your Nmap commands! With our Nmap Command Generator, you can simply say what you need Nmap to do and we will generate the command for you.

Port Specification

SWITCHEXAMPLEDESCRIPTION
-pnmap 192.168.1.1 -p 21Port scan for port x
-pnmap 192.168.1.1 -p 21-100Port range
-pnmap 192.168.1.1 -p U:53,T:21-25,80Port scan multiple TCP and UDP ports
-pnmap 192.168.1.1 -p-Port scan all ports
-pnmap 192.168.1.1 -p http,httpsPort scan from service name
-Fnmap 192.168.1.1 -FFast port scan (100 ports)
-top-portsnmap 192.168.1.1 -top-ports 2000Port scan the top x ports
-p-65535nmap 192.168.1.1 -p-65535Leaving off initial port in range makes the scan start at port 1
-p0-nmap 192.168.1.1 -p0-Leaving off end port in range
makes the scan go through to port 65535

Service and Version Detection

SWITCHEXAMPLEDESCRIPTION
-sVnmap 192.168.1.1 -sVAttempts to determine the version of the service running on port
-sV -version-intensitynmap 192.168.1.1 -sV -version-intensity 8Intensity level 0 to 9. Higher number increases possibility of correctness
-sV -version-lightnmap 192.168.1.1 -sV -version-lightEnable light mode. Lower possibility of correctness. Faster
-sV -version-allnmap 192.168.1.1 -sV -version-allEnable intensity level 9. Higher possibility of correctness. Slower
-Anmap 192.168.1.1 -AEnables OS detection, version detection, script scanning, and traceroute

OS Detection

SWITCHEXAMPLEDESCRIPTION
-Onmap 192.168.1.1 -ORemote OS detection using TCP/IP stack fingerprinting
-O -osscan-limitnmap 192.168.1.1 -O -osscan-limitIf at least one open and one closed TCP port are not found it will not try OS detection against host
-O -osscan-guessnmap 192.168.1.1 -O -osscan-guessMakes Nmap guess more aggressively
-O -max-os-triesnmap 192.168.1.1 -O -max-os-tries 1Set the maximum number x of OS detection tries against a target
-Anmap 192.168.1.1 -AEnables OS detection, version detection, script scanning, and traceroute

Timing and Performance

SWITCHEXAMPLEDESCRIPTION
-T0nmap 192.168.1.1 -T0Paranoid (0) Intrusion Detection System evasion
-T1nmap 192.168.1.1 -T1Sneaky (1) Intrusion Detection System evasion
-T2nmap 192.168.1.1 -T2Polite (2) slows down the scan to use less bandwidth and use less target machine resources
-T3nmap 192.168.1.1 -T3Normal (3) which is default speed
-T4nmap 192.168.1.1 -T4Aggressive (4) speeds scans; assumes you are on a reasonably fast and reliable network
-T5nmap 192.168.1.1 -T5Insane (5) speeds scan; assumes you are on an extraordinarily fast network

Timing and Performance Switches

SWITCHEXAMPLE INPUTDESCRIPTION
-host-timeout<time>1s; 4m; 2hGive up on target after this long
-min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout<time>1s; 4m; 2hSpecifies probe round trip time
-min-hostgroup/max-hostgroup<size<size>50; 1024Parallel host scan group sizes
-min-parallelism/max-parallelism<numprobes>10; 1Probe parallelization
-max-retries <tries>3Specify the maximum number of port scan probe retransmissions
-min-rate<number>100Send packets no slower than<number> per second
-max-rate <number>100Send packets no faster than<number> per second

NSE Scripts

SWITCHEXAMPLEDESCRIPTION
-sCnmap 192.168.1.1 -sCScan with default NSE scripts. Considered useful for discovery and safe
-script defaultnmap 192.168.1.1 -script defaultScan with default NSE scripts. Considered useful for discovery and safe
-scriptnmap 192.168.1.1 -script=bannerScan with a single script. Example banner
-scriptnmap 192.168.1.1 -script=http*Scan with a wildcard. Example http
-scriptnmap 192.168.1.1 -script=http,bannerScan with two scripts. Example http and banner
-scriptnmap 192.168.1.1 -script "not intrusive"Scan default, but remove intrusive scripts
-script-argsnmap -script snmp-sysdescr -script-args snmpcommunity=admin 192.168.1.1NSE script with arguments

Useful NSE Script Examples

COMMANDDESCRIPTION
nmap -Pn -script=http-sitemap-generator scanme.nmap.orghttp site map generator
nmap -n -Pn -p 80 -open -sV -vvv -script banner,http-title -iR 1000Fast search for random web servers
nmap -Pn -script=dns-brute domain.comBrute forces DNS hostnames guessing subdomains
nmap -n -Pn -vv -O -sV -script smb-enum*,smb-ls,smb-mbenum,smb-os-discovery,smb-s*,smb-vuln*,smbv2* -vv 192.168.1.1Safe SMB scripts to run
nmap -script whois* domain.comWhois query
nmap -p80 -script http-unsafe-output-escaping scanme.nmap.orgDetect cross site scripting vulnerabilities
nmap -p80 -script http-sql-injection scanme.nmap.orgCheck for SQL injections

Firewall / IDS Evasion and Spoofing

SWITCHEXAMPLEDESCRIPTION
-fnmap 192.168.1.1 -fRequested scan (including ping scans) use tiny fragmented IP packets. Harder for packet filters
-mtunmap 192.168.1.1 -mtu 32Set your own offset size
-Dnmap -D 192.168.1.101,192.168.1.102,192.168.1.103,192.168.1.23 192.168.1.1Send scans from spoofed IPs
-Dnmap -D decoy-ip1,decoy-ip2,your-own-ip,decoy-ip3,decoy-ip4 remote-host-ipAbove example explained
-Snmap -S www.microsoft.com www.facebook.comScan Facebook from Microsoft (-e eth0 -Pn may be required)
-gnmap -g 53 192.168.1.1Use given source port number
-proxiesnmap -proxies http://192.168.1.1:8080, http://192.168.1.2:8080 192.168.1.1Relay connections through HTTP/SOCKS4 proxies
-data-lengthnmap -data-length 200 192.168.1.1Appends random data to sent packets

Example IDS Evasion command

nmap -f -t 0 -n -Pn --data-length 200 -D
192.168.1.101,192.168.1.102,192.168.1.103,192.168.1.23 192.168.1.1

Output

SWITCHEXAMPLEDESCRIPTION
-oNnmap 192.168.1.1 -oN normal.fileNormal output to the file normal.file
-oXnmap 192.168.1.1 -oX xml.fileXML output to the file xml.file
-oGnmap 192.168.1.1 -oG grep.fileGrepable output to the file grep.file
-oAnmap 192.168.1.1 -oA resultsOutput in the three major formats at once
-oG -nmap 192.168.1.1 -oG -Grepable output to screen. -oN -, -oX - also usable
-append-outputnmap 192.168.1.1 -oN file.file -append-outputAppend a scan to a previous scan file
-vnmap 192.168.1.1 -vIncrease the verbosity level (use -vv or more for greater effect)
-dnmap 192.168.1.1 -dIncrease debugging level (use -dd or more for greater effect)
-reasonnmap 192.168.1.1 -reasonDisplay the reason a port is in a particular state, same output as -vv
-opennmap 192.168.1.1 -openOnly show open (or possibly open) ports
-packet-tracenmap 192.168.1.1 -T4 -packet-traceShow all packets sent and received
-iflistnmap -iflistShows the host interfaces and routes
-resumenmap -resume results.fileResume a scan

Helpful Nmap Output examples

COMMANDDESCRIPTION
nmap -p80 -sV -oG - -open 192.168.1.1/24 | grep openScan for web servers and grep to show which IPs are running web servers
nmap -iR 10 -n -oX out.xml | grep "Nmap" | cut -d " " -f5 > live-hosts.txtGenerate a list of the IPs of live hosts
nmap -iR 10 -n -oX out2.xml | grep "Nmap" | cut -d " " -f5 >> live-hosts.txtAppend IP to the list of live hosts
ndiff scanl.xml scan2.xmlCompare output from nmap using the ndif
xsltproc nmap.xml -o nmap.htmlConvert nmap xml files to html files
grep " open " results.nmap | sed -r ‘s/ +/ /g’ | sort | uniq -c | sort -rn | lessReverse sorted list of how often ports turn up

Miscellaneous Nmap Flags

SWITCHEXAMPLEDESCRIPTION
-6nmap -6 2607:f0d0:1002:51::4Enable IPv6 scanning
-hnmap -hnmap help screen

Other Useful Nmap Commands

COMMANDDESCRIPTION
nmap -iR 10 -PS22-25,80,113,1050,35000 -v -snDiscovery only on ports x, no port scan
nmap 192.168.1.1-1/24 -PR -sn -vvArp discovery only on local network, no port scan
nmap -iR 10 -sn -tracerouteTraceroute to random targets, no port scan
nmap 192.168.1.1-50 -sL -dns-server 192.168.1.1Query the Internal DNS for hosts, list targets only
nmap 192.168.1.1 --packet-traceShow the details of the packets that are sent and received during a scan and capture the traffic.

You are only doing yourself a disservice by failing to learn and utilize all of Nmap’s features. It is the first go-to tool you will use in the scanning and enumeration stage of many assessments, setting the foundation for the rest of your pentest.

Keep a copy of this Nmap cheat sheet to refer back to, and consider our Complete Nmap Ethical Hacking Course. It, and many other ethical hacking courses, are available in our VIP Member’s Section.

Frequently Asked Questions

What is Nmap, and why is it used?

Nmap is a free network scanning tool used to discover hosts and services on a network by analyzing responses to various packets and requests.

What is the Nmap command used for?

Penetration testers and network administrators will use Nmap to discover machines on a network and their open ports, running services, operating systems, and a wealth of other useful information.

Is Nmap scanning legal?

This depends on your jurisdiction. In many places, the answer is no, not without prior permission from the owner of the site or network.

We recommend reading a more complete answer in our article, Is Port Scanning Legal?

What can we hack with Nmap?

Nmap is a tool used for scanning and enumeration. Hackers and penetration testers use the information gathered to see what the available attack surface is.

However, there are a great number of NSE scripts that can perform such actions as password brute forcing, checking for backup and configuration files, searching for remote file inclusion (RFI) vulnerabilities, and testing default credentials.

How do I scan an IP with Nmap?

A basic scan of a single IP address is as easy as:
nmap <ip>

This will return if the host is up and responding to ping, what ports are open, and what services are running on them. More complex commands can be found in the cheat sheet above.

Is it OK to Nmap Google?

The long answer is, it depends on your jurisdiction. The short answer is, probably not and you shouldn’t do it. Even if it isn’t illegal where you live, it will most certainly violate Google’s terms of service.

Do firewalls block Nmap?

Firewalls can block access to ports, which would indeed block Nmap. Nmap does have flags to attempt to evade firewalls and intrusion detection systems, which we have listed in the cheat sheet above.

Is Nmap a vulnerability?

After you have installed Nmap on your host system, an over-ambitious antivirus program may flag it as malicious. So long as you have downloaded it from the official Nmap website, it is safe to have installed.

Can Nmap bypass a firewall?

Nmap has several optional services which can attempt to bypass firewalls and spoof its scans. See the Firewall / IDS Evasion and Spoofing section above for details.

Can Nmap hack WiFi?

Nmap has many NSE scripts designed to brute force different services and logins. Depending on the login portal, there may be a relevant script to do so.

More realistically, Nmap would be used to enumerate the network, and one of many free programs better suited to WiFi hacking would be used afterward.

Can Nmap crack passwords?

Nmap has many brute force scripts which will automate password login attempts on various services, such as MySQL, Telenet, and POP3. This may provide a quick win, but password attacks are better handled by tools dedicated to that purpose, such as THC Hydra.

How do I read Nmap results?

Fortunately, even the more complex Nmap scans display their results in a clear and easy-to-follow manner. You also have the ability to output the data in various forms, including as an XML or grepable file (see the Output section for details).

You can also see our Zenmap vs. Nmap article to learn about the graphical version of the tool.

Level Up in Cyber Security: Join Our Membership Today!

Nmap Cheat Sheet 2024: All the Commands, Flags & Switches (1)
Nmap Cheat Sheet 2024: All the Commands, Flags & Switches (2)

MEMBERSHIP

  • Nmap Cheat Sheet 2024: All the Commands, Flags & Switches (3)

    Nathan House

    Nathan House is the founder and CEO of StationX. He has over 25 years of experience in cyber security, where he has advised some of the largest companies in the world. Nathan is the author of the popular "The Complete Cyber Security Course", which has been taken by over half a million students in 195 countries. He is the winner of the AI "Cyber Security Educator of the Year 2020" award and finalist for Influencer of the year 2022.

Nmap Cheat Sheet 2024: All the Commands, Flags & Switches (2024)
Top Articles
Making Mixes 101 (and a brownie mix recipe!)
Cornbread Tamale Pie Recipe
Sdn Md 2023-2024
Lowe's Garden Fence Roll
Minooka Channahon Patch
Mackenzie Rosman Leaked
Valley Fair Tickets Costco
Die Windows GDI+ (Teil 1)
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Caresha Please Discount Code
General Info for Parents
Enderal:Ausrüstung – Sureai
Wisconsin Women's Volleyball Team Leaked Pictures
Wgu Admissions Login
Jvid Rina Sauce
Gma Deals And Steals Today 2022
Walgreens San Pedro And Hildebrand
Bridge.trihealth
Caledonia - a simple love song to Scotland
Walgreens Alma School And Dynamite
Azur Lane High Efficiency Combat Logistics Plan
Strange World Showtimes Near Savoy 16
Rek Funerals
Weathervane Broken Monorail
Urbfsdreamgirl
Dr. Nicole Arcy Dvm Married To Husband
Marokko houdt honderden mensen tegen die illegaal grens met Spaanse stad Ceuta wilden oversteken
Coindraw App
Sensual Massage Grand Rapids
Will there be a The Tower season 4? Latest news and speculation
Rainfall Map Oklahoma
031515 828
Barbie Showtimes Near Lucas Cinemas Albertville
Kiddie Jungle Parma
Ancestors The Humankind Odyssey Wikia
Opsahl Kostel Funeral Home & Crematory Yankton
Litter-Robot 3 Pinch Contact & DFI Kit
THE 10 BEST Yoga Retreats in Konstanz for September 2024
Avance Primary Care Morrisville
Ludvigsen Mortuary Fremont Nebraska
Deshuesadero El Pulpo
Conroe Isd Sign In
Complete List of Orange County Cities + Map (2024) — Orange County Insiders | Tips for locals & visitors
Gopher Hockey Forum
Pa Legion Baseball
Ladyva Is She Married
Tlc Africa Deaths 2021
CrossFit 101
855-539-4712
Congruent Triangles Coloring Activity Dinosaur Answer Key
The top 10 takeaways from the Harris-Trump presidential debate
What your eye doctor knows about your health
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 5852

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.