Win In Life Academy

Nmap Cheatsheet – Essential Commands for Network Scanning 

Share This Post on Your Feed 👉🏻

Nmap Cheatsheet Overview
This Nmap cheatsheet explains basic and advanced Nmap commands used for network scanning, port detection, and vulnerability assessment, making it a practical reference for beginners as well as experienced cybersecurity professionals.

If you’ve started learning cybersecurity, you’ve probably heard Nmap mentioned in every tutorial, course, and job description. There’s a reason: it’s the one tool that shows you what’s happening on a network, the open doors, the running services, the devices that shouldn’t be there. Whether you’re scanning a corporate network for vulnerabilities, conducting penetration tests, or investigating potential security breaches, Nmap is the foundational tool that every security professional, from SOC analysts to penetration testers, uses to understand what’s exposed and where the risks lie. 

Here’s why you need this cheatsheet: Nmap has over 100 command options and combinations. Without a structured reference, you’ll waste hours searching for the right scan type, forget critical flags during assessments, or miss vulnerabilities because you didn’t know which command reveals them. A cheatsheet eliminates that friction; it’s your quick reference when you’re in the middle of a lab exercise, working on a capture-the-flag challenge, or conducting your first real vulnerability assessment and can’t afford to fumble through documentation. 

We’re breaking down each command with clear explanations of what it does, when to use it, and what the results actually mean. No assumptions that you already know this stuff, just practical guidance that gets you working with Nmap confidently. 

nmap cheatsheet

Nmap’s flexibility in defining scan targets is one of its most powerful features. Here are several ways you can specify which hosts or networks to scan, tailored to your needs. 

Method Description Example
Single IPScan a single host.nmap 192.168.1.1
Multiple IPsScan specific hosts by providing their IPs.nmap 192.168.1.1 192.168.1.2
IP RangeScan a range of IP addresses.nmap 192.168.1.1-10
CIDR NotationScan an entire subnet using CIDR notation.nmap 192.168.1.0/24
HostnameScan using a domain or hostname.nmap example.com
From FileScan targets listed in a file.nmap -iL targets.txt
Random TargetsScan a random selection of hosts.nmap -iR 10
Excluding TargetsSkip specific hosts during a scan.nmap 192.168.1.0/24 --exclude 192.168.1.5
Excluding From FileSkip hosts listed in a file.nmap 192.168.1.0/24 --excludefile exclude.txt

When scanning large networks, it’s good practice to organize your targets logically. This allows you to efficiently scan different segments or types of devices by using separate files for each group. 

Method Description Example
Web Server Scan Scan all web servers by specifying a file containing their IP addresses. nmap -iL webservers.txt -p 80,443 -oA web_scan
Database Server Scan Scan all database servers by specifying a file containing their IP addresses. nmap -iL dbservers.txt -p 1433,3306,5432 -oA db_scan

Port scanning is one of Nmap’s core features, and it offers a variety of scanning techniques to identify open ports and services on a target. Below is a breakdown of the most common port scanning options: 

Command Description Example When to Use
-sSTCP SYN scan (default)nmap -sS 192.168.1.1For general-purpose scanning; stealthier than a full TCP connect scan.
-sTTCP connect scannmap -sT 192.168.1.1When raw packet privileges are not available.
-sUUDP scannmap -sU 192.168.1.1To detect UDP services such as DNS, SNMP, and other UDP-based services.
-sATCP ACK scannmap -sA 192.168.1.1To map firewall rulesets and determine whether ports are filtered.

Control the specific ports Nmap scans with these options to focus on relevant services: 

Command Description Example When to Use
DefaultScan top 1000 portsnmap 192.168.1.1Quick scans of common services on a target.
-p 22Scan port 22 onlynmap -p 22 192.168.1.1When you need to check a specific service such as SSH.
-p 22-100Scan a range of portsnmap -p 22-100 192.168.1.1Useful when focusing on a specific port range.
-p-Scan all ports (1–65535)nmap -p- 192.168.1.1Thorough scans when time allows full enumeration.
-p http,httpsScan by service namenmap -p http,https 192.168.1.1When you know which services (HTTP/HTTPS) to check.
-p T:22,U:53Specify TCP and UDP portsnmap -p T:22,U:53 192.168.1.1For mixed protocol scanning such as SSH (TCP) and DNS (UDP).
–top-ports 100Scan top 100 portsnmap --top-ports 100 192.168.1.1Quick overview of the most commonly used ports.
-FFast scan (top 100 ports)nmap -F 192.168.1.1Fast reconnaissance when speed is more important than depth.

Before performing detailed port scanning, identifying which hosts are online is crucial. A 2023 study on network scanning efficiency found that conducting proper host discovery could reduce overall scan time by up to 70% on large networks. 

Command Description Example Best For
-snPing scan (no port scan)nmap -sn 192.168.1.0/24Quick host discovery on friendly networks.
-PnSkip host discoverynmap -Pn 192.168.1.1Scanning hosts that block ICMP.
-PS22,80TCP SYN ping on specified portsnmap -PS22,80 192.168.1.0/24Networks that block standard ICMP pings.
-PA22,80TCP ACK ping on specified portsnmap -PA22,80 192.168.1.0/24Bypassing stateful firewalls.
-PU53UDP ping on port 53nmap -PU53 192.168.1.0/24Networks with active UDP services.
-PEICMP echo requestnmap -PE 192.168.1.0/24Standard ping sweep.
-PPICMP timestamp requestnmap -PP 192.168.1.0/24When ICMP echo requests are blocked.
-PMICMP address mask requestnmap -PM 192.168.1.0/24Alternative when echo requests are blocked.
-PRARP scan (local network)nmap -PR 192.168.1.0/24Fast and reliable scanning on local networks.
-nNo DNS resolutionnmap -n 192.168.1.0/24Speeding up scans when DNS lookups are unnecessary.
-RForce DNS resolutionnmap -R 192.168.1.0/24Resolving hostnames for all scanned IP addresses.

Certificate in Data Analytics with  

AI Foundation 

Build practical skills to analyze, interpret, and visualize data generated from real-world systems and operations. Learn how to work with datasets, identify patterns, create dashboards, and support data-driven decision-making across technology and business domains. 

IN PARTNERSHIP WITH
4.8(3,235 ratings)

Your approach to host discovery should be tailored based on the network environment: 

  • Local Network: For maximum efficiency, use ARP scanning. 

nmap -PR -sn 192.168.1.0/24 

  • Remote Network with Firewall: Use a combination of multiple ping techniques to bypass firewalls. 

nmap -PS22,80,443 -PA3389 -PU161 -sn 10.0.0.0/24 

  • Unknown Network: Employ a comprehensive scanning strategy to detect active hosts. 

nmap -PE -PP -PS21,22,23,25,80,443,3389 -PA80,443 -sn 172.16.0.0/24 

Nmap provides timing templates that allow you to control the scan speed and level of aggressiveness. According to Nmap’s performance metrics, selecting the appropriate timing template can drastically reduce scan times, potentially turning a process that takes hours into one that takes just minutes. 

Command Description Example When to Use
-T0Paranoid (very slow)nmap -T0 192.168.1.1Use for IDS evasion and minimal impact on the network.
-T1Sneaky (slow)nmap -T1 192.168.1.1Ideal for IDS evasion while maintaining a low profile.
-T2Polite (slower than default)nmap -T2 192.168.1.1When minimal bandwidth usage is required.
-T3Normal (default)nmap -T3 192.168.1.1Standard, balanced scanning approach.
-T4Aggressive (faster)nmap -T4 192.168.1.1Best for fast, reliable networks and modern systems.
-T5Insane (very fast)nmap -T5 192.168.1.1Suitable for high-bandwidth environments with some accuracy trade-offs.

For greater control over your scan parameters, consider adjusting the following options: 

Command Description Example Impact
–min-rate=XSet a minimum packet send ratenmap --min-rate=100 192.168.1.1Ensures the scan maintains a minimum execution speed.
–max-rate=XLimit the maximum packet send ratenmap --max-rate=50 192.168.1.1Restricts bandwidth usage during scanning.
–min-parallelism=XSpecify the minimum number of parallel probesnmap --min-parallelism=10 192.168.1.1Increases scan concurrency and speed.
–max-parallelism=XLimit the maximum number of parallel probesnmap --max-parallelism=10 192.168.1.1Reduces concurrency to minimize network impact.
–min-hostgroup=XScan a minimum number of hosts in parallelnmap --min-hostgroup=50 192.168.1.0/24Improves efficiency when scanning large target sets.
–max-hostgroup=XLimit the number of hosts scanned in parallelnmap --max-hostgroup=50 192.168.1.0/24Controls memory usage and system load.
–host-timeout=XSet a timeout for slow or unresponsive hostsnmap --host-timeout=30m 192.168.1.0/24Prevents scans from stalling on slow hosts.
–scan-delay=XIntroduce a delay between probesnmap --scan-delay=1s 192.168.1.1Helps evade rate-limiting and IDS defenses.
–max-retries=XSet a limit on retry attemptsnmap --max-retries=2 192.168.1.0/24Speeds up scans by reducing repeated probes.

1. Failing to Specify the Correct Target 

  • Issue: Scanning without clearly defining the target(s). 
  • Solution: Always ensure you specify the correct IP addresses or ranges to avoid accidental scans of the local machine or incomplete scans. 
  • Example: Instead of using nmap, always use a specific target like nmap 192.168.1.0/24. 

2. Missing Service Version Detection 

  • Issue: Not using the -sV option to detect service versions. 
  • Solution: To gather more detailed information about services running on open ports, include the -sV flag in your command. 
  • Example: Use nmap -sV <target> to get service versions. 

3. Running Scans Without Sufficient Privileges 

  • Issue: Some scan types (like SYN scan) require administrative privileges to execute. 
  • Solution: Run Nmap with elevated privileges (e.g., sudo on Linux/macOS) to access advanced scan options. 
  • Example: Use sudo nmap -sS <target> for a SYN scan. 

4. Overlooking Host Discovery 

  • Issue: Not accounting for hosts that block ICMP requests. 
  • Solution: Use the -Pn option to disable host discovery and ensure all hosts are scanned, even those that do not respond to pings. 
  • Example: nmap -Pn <target> 

5. Using Default Timing Template 

  • Issue: Relying on Nmap’s default timing, which may not suit your environment. 
  • Solution: Adjust the timing template to either speed up scans or reduce detection chances, depending on your needs. 
  • Example: Use -T4 for faster scans or -T0 for stealthier ones. 

6. Selecting the Wrong Scan Type 

  • Issue: Using an inappropriate scan type for your objective (e.g., missing a UDP scan or TCP SYN scan). 
  • Solution: Choose the scan type that best fits your goal, such as -sS for SYN scans or -sU for scanning UDP services. 
  • Example: nmap -sS <target> for a stealthy scan. 

7. Not Using Proper Output Formats 

  • Issue: Sticking with the default output format, which can be difficult to parse. 
  • Solution: Use alternative output formats like XML or greppable formats for easier analysis and integration with other tools. 
  • Example: nmap -oX scan_results.xml <target> 

8. Scanning All Ports Without Necessity 

  • Issue: Scanning all 65535 ports when only a few are relevant. 
  • Solution: Limit the scan to specific ports or port ranges to save time and focus on the critical services. 
  • Example: nmap -p 22,80,443 <target> to scan only key ports. 

9. Ignoring Evasion Techniques 

  • Issue: Running scans that are easily detected by firewalls or IDS/IPS systems. 
  • Solution: Implement evasion techniques, such as delaying probes or using decoys, to bypass security defenses. 
  • Example: nmap -D RND:10 <target> for decoy scanning. 

10. Misinterpreting Scan Results 

  • Issue: Failing to properly analyze and understand the scan output. 
  • Solution: Take time to review the results thoroughly, using additional options like -O for OS detection and –script for vulnerability scanning. 
  • Example: Use nmap -O <target> for OS detection or nmap –script=vuln <target> to identify vulnerabilities. 

Cybersecurity Course with  

Online Certifications 

Build hands-on cybersecurity skills to protect digital systems, networks, and data from real-world cyber threats. Learn how security operations, access control, risk management, and incident response work in modern enterprise and cloud environments. 

IN PARTNERSHIP WITH
4.8(3,235 ratings)

While Nmap is a powerful tool for network scanning, it also has the capability to handle complex and specialized situations that may not be covered in basic usage. These advanced scenarios often arise in more sophisticated or unconventional network environments. Below are some examples and explanations: 

  • Scenario: Firewalls and Intrusion Detection/Prevention Systems (IDS/IPS) often block or detect Nmap scans, especially if the scan is too aggressive or resembles attack patterns. 
  • Solution: Use more subtle scan types like -sS (SYN scan) or -PA (TCP ACK scan) to bypass firewalls. You can also use -T1 for slow scans and -D for decoy scanning to reduce detection. 
  • Examplenmap -sS -D RND:10 -T2 192.168.1.1 
  • Scenario: When scanning over a VPN or through a proxy, Nmap scans may be unreliable or slower due to routing limitations, or the VPN may block certain types of traffic. 
  • Solution: Ensure the VPN allows for the type of scanning you want to perform. Use the -S flag to spoof the source IP if necessary and the –proxy option to route traffic through a proxy. 
  • Example:  nmap –proxy socks5://proxy.example.com:1080 192.168.1.1 
  • Scenario: When scanning a target behind a NAT (e.g., in a home or enterprise network), Nmap may fail to reach the actual machine due to the translation of IP addresses. 
  • Solution: Use port forwarding on the NAT device or scan the NAT gateway and forward traffic. Additionally, scanning with -sT (TCP connect) is often more effective behind NAT than SYN scanning. 
  • Example:  nmap -sT 192.168.1.1 
  • Scenario: Scanning IPv6 addresses is different from IPv4, given the vastly larger address space and different network configurations. It may also require specific tools or modifications. 
  • Solution: Use the -6 flag in Nmap to enable IPv6 scanning. Be aware that some systems might not respond to IPv6 scan probes as expected. 
  • Example:  nmap -6 -sS 2001:db8::1 
  • Scenario: Accurately detecting the operating system (OS) of a target machine is essential for penetration testing and vulnerability assessment. However, some devices and firewalls block OS fingerprinting attempts. 
  • Solution: Use the -O option for OS detection but be aware that firewalls or certain devices may block or distort these probes. You may need to employ evasion techniques to avoid detection. 
  • Example:  nmap -O 192.168.1.1 

When you run an Nmap scan, it’s easy to misinterpret the results, especially when Nmap doesn’t show everything you expect. Here’s an analysis of some of the “silent” parts of Nmap and what they really mean for your next move: 

  1. No Response = Filtered/Stealthed 
  • What it means: No response could indicate a filtered or stealthed port. 
  • Next move: Use -Pn to skip host discovery or try SYN scans (-sS). 
  1. Closed vs. Filtered Ports 
  • What it means: “Closed” is rejected; “filtered” is blocked by a firewall. 
  • Next move: Probe filtered ports with -PA or -PS. 
  1. Version Detection Fails 
  • What it means: Services might obfuscate responses or firewalls to block detection. 
  • Next move: Use Nmap scripts (–script) for more detailed detection. 
  1. Host Down = Likely Firewall 
  • What it means: “Host down” usually means ICMP is blocked. 
  • Next move: Use -Pn to bypass host discovery. 
  1. Experience vs. Beginners 
  • What it means: Experienced users know how to handle ambiguous results. 
  • Next move: Beginners should start with basic scans and progress to advanced techniques. 
  • Unauthorized Scanning = Fireable Offense: 
    Scanning your company’s network without authorization can lead to termination. Always secure permission beforehand. 
  • Scanning Your ISP or Neighbor’s Wi-Fi = Illegal: 
    Scanning your ISP’s infrastructure or your neighbor’s Wi-Fi without consent is illegal in most countries. 
  • Your Own VMs or Lab Environments: No issues here. 
  • HackTheBox/TryHackMe: Legal and secure environments designed for practice. 
  • Employer Networks (with Written Permission): Always obtain written consent. 

Authorization Template: 

Authorization to Perform Network Scan 

I, [Your Name], request permission to conduct a network scan on [Company Name]’s infrastructure for [specific purpose]. This will be done on [network/servers], per the company’s security policies. 

Signed, 
[Your Name] 
[Date] 

Conclusion 

Mastering Nmap in complex and edge-case scenarios is an essential skill for anyone aspiring to succeed in cybersecurity. Whether you’re conducting scans through firewalls, working with NAT configurations, or performing OS detection on challenging networks, gaining expertise in advanced scanning techniques will enhance your ability to identify vulnerabilities and secure systems effectively. 

At Win in Life Academy, we offer a comprehensive Cybersecurity Course tailored to provide you with the knowledge and hands-on experience needed to handle these advanced situations. With a focus on industry-standard tools like Nmap, our course equips you to excel in network scanning, vulnerability assessments, and proactive threat prevention 

3. What are the most important basic Nmap commands to learn first? 
Beginners should start with nmap <target>, -sS, -p, -sn, and -sV to understand host discovery and port scanning. 

Leave a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Get updates and learn from the best

Please confirm your details

Call Now Button