🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now β†’
Menu

Categories

Nmap Network Scanning: Complete Beginner's Guide (2026)

Nmap Network Scanning: Complete Beginner's Guide (2026)

Quick Summary: Nmap (Network Mapper) is the most popular open-source network scanning tool. It discovers hosts and services on a network by sending packets and analyzing responses. System administrators use Nmap to inventory network devices, detect open ports, and identify security vulnerabilities. This guide covers everything from basic scans to advanced scripting.

Nmap network scanning and security auditing

What Is Nmap?

Nmap is a free, open-source tool for network discovery and security auditing. Created by Gordon Lyon in 1997, Nmap has become the industry standard for network reconnaissance. It sends specially crafted packets to target hosts and analyzes responses to determine what hosts are available, what services they run, what operating systems they use, and what security measures are in place.

Nmap is included in virtually every penetration testing toolkit and is used daily by network administrators worldwide for legitimate security auditing.

Installing Nmap

  • Debian/Ubuntu: sudo apt install nmap
  • RHEL/AlmaLinux/Rocky: sudo dnf install nmap
  • macOS: brew install nmap
  • Verify: nmap --version

Essential Nmap Scan Types

Scan TypeCommandPurposeSpeed
TCP Connectnmap -sT targetFull TCP connection (reliable)Moderate
SYN Stealthnmap -sS targetHalf-open scan (stealthier, root required)Fast
UDP Scannmap -sU targetScan UDP ports (DNS, DHCP, SNMP)Slow
Ping Sweepnmap -sn 192.168.1.0/24Discover live hosts, no port scanVery Fast
Version Detectionnmap -sV targetIdentify service versionsModerate
OS Detectionnmap -O targetIdentify operating systemModerate
Aggressivenmap -A targetOS + version + scripts + tracerouteSlow

Practical Nmap Commands

Host Discovery

  1. Single host: nmap 192.168.1.1 β€” Scans 1000 most common ports
  2. Subnet: nmap 192.168.1.0/24 β€” All devices on a /24 network
  3. Multiple targets: nmap 192.168.1.1 192.168.1.5 192.168.1.10
  4. From file: nmap -iL targets.txt
  5. Exclude hosts: nmap 192.168.1.0/24 --exclude 192.168.1.1

Port Scanning

  1. Specific ports: nmap -p 80,443,8080 target
  2. Port range: nmap -p 1-1024 target
  3. All 65535 ports: nmap -p- target (thorough but slow)
  4. Top 100: nmap --top-ports 100 target
  5. Fast scan: nmap -F target

Service and OS Detection

  1. Service versions: nmap -sV target
  2. Intense detection: nmap -sV --version-intensity 5 target
  3. OS detection: nmap -O target (requires root)
  4. Combined: nmap -sV -O -sC target

Nmap Scripting Engine (NSE)

NSE extends Nmap with hundreds of scripts for vulnerability detection and information gathering:

  • nmap --script vuln target β€” Run all vulnerability scripts
  • nmap --script ssl-heartbleed target β€” Check specific vulnerability
  • nmap --script http-title target β€” Get webpage titles
  • nmap --script dns-brute target β€” DNS subdomain enumeration
  • nmap --script ssh-auth-methods target β€” Check SSH auth methods
  • nmap --script-help ssl* β€” Help on SSL scripts

Output Formats

  • nmap -oN scan.txt target β€” Normal text
  • nmap -oX scan.xml target β€” XML (for tools)
  • nmap -oG scan.gnmap target β€” Grepable output
  • nmap -oA scan target β€” All three formats

Understanding Port States

StateMeaningImplication
openService listening, accepting connectionsAccessible β€” verify if intentional
closedPort accessible but no serviceHost reachable, port unused
filteredCannot determine state (firewall)Firewall dropping packets
unfilteredAccessible but state uncertainRare β€” ACK scans
open|filteredCannot distinguish open/filteredCommon with UDP scans

Timing and Performance

Nmap timing templates control scan speed and stealth:

FlagNameUse Case
-T0ParanoidIDS evasion (extremely slow)
-T1SneakyIDS evasion (slow)
-T2PoliteReduced bandwidth usage
-T3NormalDefault timing
-T4AggressiveFast, reliable networks
-T5InsaneVery fast, may miss ports

Ethics and Legal Considerations

  • Only scan networks you own or have explicit written permission to scan
  • Unauthorized scanning is illegal in most jurisdictions
  • Start with less aggressive scans and escalate only when needed
  • Save results for documentation and compliance
  • Schedule regular scans to detect unauthorized changes

Frequently Asked Questions

Which is the best Nmap command for port scanning?

For comprehensive scanning use nmap -sV -sC -O target which combines version detection, default scripts, and OS detection. For quick scans use nmap -F target which scans only the top 100 ports.

Is Nmap legal to use?

Nmap itself is legal software. However, scanning networks without authorization is illegal in most countries. Always scan only your own systems or those you have written permission to test.

What is the difference between -sS and -sT scans?

-sS (SYN scan) sends SYN and waits for SYN-ACK without completing TCP handshake β€” faster, stealthier, requires root. -sT (Connect scan) completes the full connection β€” slower but works without root.

How long does a full port scan take?

A full scan of all 65535 ports typically takes 15-30 minutes per host. Use -T4 to speed up or --top-ports 1000 to scan common ports in seconds.

Related Resources

Share this article:
Dargslan Editorial Team (Dargslan)
About the Author

Dargslan Editorial Team (Dargslan)

Collective of Software Developers, System Administrators, DevOps Engineers, and IT Authors

Dargslan is an independent technology publishing collective formed by experienced software developers, system administrators, and IT specialists.

The Dargslan editorial team works collaboratively to create practical, hands-on technology books focused on real-world use cases. Each publication is developed, reviewed, and...

Programming Languages Linux Administration Web Development Cybersecurity Networking

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.