Nmap_ The Complete Guide From Beginner to Advanced
Nmap_ The Complete Guide From Beginner to Advanced
Table of Contents
1. Introduction to Nmap
2. Installation and Basic Setup
3. Understanding Network Basics
4. Basic Scanning Techniques
5. Port Scanning Deep Dive
6. Host Discovery Methods
7. Service and Version Detection
8. Operating System Detection
9. Timing and Performance
10. Firewall and IDS Evasion
11. NSE Scripting
12. Output Formats and Reporting
13. Advanced Techniques
14. Real-World Scenarios
15. Best Practices and Ethics
Introduction to Nmap
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 1/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
Nmap (Network Mapper) is a powerful open-source tool used for network discovery and
security auditing. It is widely used by network administrators, penetration testers, and
security professionals to assess network security, map out networks, detect vulnerabilities,
and explore services and devices running in a network.
Basic Concepts
Before diving into the scanning commands, let's define a few key terms:
Port: A network endpoint for communication services (e.g., HTTP uses port 80).
Service: The application or program running on a particular port.
State: Describes the current condition of a port, which could be open, closed, or
filtered.
Protocol: The set of rules governing communication (e.g., TCP, UDP).
Installing Nmap
On Linux:
For Debian/Ubuntu:
Verifying Installation:
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 2/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
$ nmap --version
Nmap version 7.93 ( https://nmap.org )
Platform: x86_64-pc-linux-gnu
This should return the version of Nmap that is installed, confirming the installation.
Target Specification
nmap 192.168.1.1
nmap 192.168.1.1-10
nmap 192.168.1.0/24
nmap example.com
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 3/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
1. Simple Scan
A simple Nmap scan will check the top 1000 most common ports on a target by default.
$ nmap 192.168.1.1
Starting Nmap 7.93
Nmap scan report for 192.168.1.1
Host is up (0.0023s latency).
Not shown: 997 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
Output Breakdown:
To scan specific ports, use the -p flag followed by a comma-separated list of ports or a
range.
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 4/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
Nmap scan report for 192.168.1.1
PORT STATE SERVICE
80/tcp open http
443/tcp open https
Output Explanation:
The SYN scan is the most popular and stealthy scan type. It sends a SYN packet (part of the
TCP handshake) to each port and listens for responses.
Explanation:
SYN-ACK: Port 22, 80, and 443 are open (responded with a SYN-ACK).
RST: No response, so the port is filtered (e.g., port 21).
Filtered: Nmap can't determine whether the port is open or closed due to firewall
filtering.
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 5/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
A TCP Connect scan completes the handshake with the target port, unlike the SYN scan. This
is less stealthy but more accurate.
Use Cases:
Scans for open UDP ports. UDP doesn’t have the same handshake as TCP, so detecting open
ports is more challenging.
Explanation:
open: Received a response on port 53, indicating the DNS service is available.
open|filtered: No response from port 161, so it is either open or filtered.
1. Ping Scan
A ping scan is useful for determining which hosts are online without scanning ports.
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 6/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
Explanation:
Nmap only performs a host discovery to see which devices are up on the network.
The result indicates that only two hosts are up.
2. ARP Scan
An ARP scan is used for local network host discovery. It uses ARP packets to identify devices.
3. No Ping Scan
If the target does not respond to ping requests, you can skip host discovery entirely with -
Pn .
To detect the services and their versions running on open ports, use -sV .
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 7/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
Explanation:
SERVICE: Identifies the service running on the port (e.g., SSH, HTTP, HTTPS).
VERSION: Shows the version of the service (e.g., OpenSSH 8.2p1, nginx 1.18.0).
For more intense scanning, including script scanning and OS detection, use the -A flag.
Basic OS Detection
-O` option.
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 8/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
Explanation:
Aggressive OS Detection
You can use more aggressive OS detection with the --osscan-guess option to guess less
obvious OS types.
Timing Templates
Nmap provides several timing templates to adjust the scan's speed and stealthiness.
Explanation:
-T0 (Paranoid): Slowest scan to avoid detection, but increases scan time.
-T4 (Aggressive): Faster scan, suitable for most environments.
1. Fragment Packets
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 9/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
To avoid detection by firewalls or Intrusion Detection Systems (IDS), you can fragment
packets.
2. Custom MTU
You can set a custom Maximum Transmission Unit (MTU) to evade detection.
3. Decoy Scanning
NSE Scripting
Default Scripts
Nmap supports script scanning using the Nmap Scripting Engine (NSE) to detect
vulnerabilities and other network services.
Specific Scripts
To run specific scripts (e.g., vulnerability scanning), use the --script option.
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 10/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
Normal Output
XML Output
Advanced Techniques
1. Comprehensive Scan
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 11/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
Real-World Scenarios
Scan a web server for vulnerabilities and services running on HTTP/HTTPS ports.
2. Network Inventory
3. Vulnerability Assessment
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 12/13
2/5/25, 3:28 PM Nmap: The Complete Guide From Beginner to Advanced
Remember, with great power comes great responsibility. Always ensure you have permission
before scanning networks or devices.
https://blog.geekinstitute.org/2024/11/nmap-network-mapping-and-security-scanning.html 13/13