Complete Guide to Using Nmap for Network Security

πŸ“± Mobile Security Tips

Sarah Chen — iOS Security Specialist

What is Nmap?

Nmap (Network Mapper) is an open-source tool for network exploration and security auditing. It is widely used by security professionals to discover hosts and services on a computer network by sending packets and analyzing the responses.

Installation

To install Nmap, you can use the package manager for your operating system:

  • Ubuntu/Debian: sudo apt install nmap
  • CentOS/Fedora: sudo yum install nmap
  • Windows: Download the installer from nmap.org.

Basic Syntax

The basic syntax of Nmap is:

nmap [options] 

Discovery

Ping Scan

Identify live hosts in a network:

nmap -sn 192.168.1.0/24

This sends ICMP echo request packets to the specified subnet.

Service Version Detection

Determine service versions running on ports:

nmap -sV 192.168.1.1

Use this for detailed version information.

Scanning

TCP Connect Scan

Perform a standard TCP connect scan:

nmap -sT 192.168.1.1

Full Range of Ports

Scan all 65535 ports on a target:

nmap -p- 192.168.1.1

Exploitation

TCP ACK Scan

Discover if ports are filtered:

nmap -sA 192.168.1.1

Analysis

OS Detection

Identify the operating system of the target:

nmap -O 192.168.1.1

Evasion

Decoy Scan

Obfuscate the source of the scan to avoid detection:

nmap -D RND:10 192.168.1.1

Reporting

XML Output

Generate an XML output file:

nmap -oX output.xml 192.168.1.1

Quick Reference Table

Flag Description
-sS SYN scan (stealth scan)
-p- Scan all ports
-oN Normal output

Pro Tips

  • Timing Options: Use -T4 for faster scanning during active hours.
  • Use Grepable Output: For quick reviews, consider -oG output.gnmap.

Real-World Examples

Find Open HTTP Ports

nmap -p 80,443 -sV 192.168.1.1

Inventory Network Devices

nmap -sP 192.168.1.0/24

Scan with Specific Interface

nmap -e eth0 192.168.1.0/24