Understanding a network is one of the first skills an aspiring ethical hacker should develop. Before assessing security, you need to understand which devices are connected, which services they provide and how they communicate.
Nmap (Network Mapper) is one of the most widely used tools for network discovery and security assessment. It helps security professionals identify active hosts, discover open ports, examine services and gather information about network infrastructure.
Before using Nmap to discover devices and services on a network, it is important to understand how computers communicate. Learning networking fundamentals, including IP addresses, ports, protocols and network communication, will help you understand what Nmap is detecting during a scan.
For beginners, learning Nmap provides a practical introduction to network scanning and helps build the foundation for ethical hacking and penetration testing.
NEW TO ETHICAL HACKING?
Start your ethical hacking journey with our FREE Beginner Ethical Hacker Starter Kit (2026 Edition).
Get beginner-friendly guidance to understand the fundamentals of ethical hacking and take your first steps into cybersecurity.
In this guide, we will explore how Nmap works, its important features, commonly used commands and a beginner-friendly lab exercise.
What Is Nmap?
Nmap is a free, open-source network scanning and discovery tool. It is used by network administrators and security professionals to examine networks and identify devices and services.
Nmap can help you:
- Discover active devices on a network.
- Identify open, closed and filtered ports.
- Detect services running on open ports.
- Identify service versions.
- Perform operating system detection.
- Examine network characteristics using its scripting capabilities.
For example, a security administrator might use Nmap to identify devices on an internal network and determine whether unnecessary services are exposed. Nmap is available for Linux, Windows and macOS.
Network discovery is an important part of understanding an organization’s attack surface and identifying potential security risks. If you are new to the field, learning the basic cybersecurity fundamentals will help you understand why tools such as Nmap are used during security assessments.
Understanding Ports and Network Scanning
Before using Nmap, understand what a port is. A port is a logical communication endpoint used by network applications. Different services commonly use different port numbers.
Some familiar examples include:
| Port | Common service |
|---|---|
| 21 | FTP |
| 22 | SSH |
| 25 | SMTP |
| 53 | DNS |
| 80 | HTTP |
| 443 | HTTPS |
| 3389 | Remote Desktop Protocol |
A port scan examines a target system to determine the state of its ports.
Nmap commonly reports these states:
- Open: An application is accepting connections on the port.
- Closed: The port is reachable, but no application is listening.
- Filtered: Nmap cannot determine the port state because filtering or another network condition prevents a clear response.
- Open|Filtered: Nmap cannot distinguish between an open port and a filtered port.
- Closed|Filtered: Nmap cannot determine whether a port is closed or filtered in certain scanning situations.
Understanding these states helps you interpret scan results correctly. An open port is not automatically a vulnerability; it indicates that a service is accepting connections.
Installing Nmap
Nmap can be installed on different operating systems.
Linux: Nmap is commonly used in Linux-based cybersecurity environments, making it useful for beginners to become familiar with the operating system. Understanding Linux fundamentals, including the terminal, file system and basic commands, will make it easier to install and use security tools such as Nmap.
Many Linux distributions provide Nmap through their package managers. On Debian-based systems, for example, you can use:
sudo apt update
sudo apt install nmap
Windows: Nmap is also available for Windows, allowing beginners to perform network discovery without installing a Linux distribution. Understanding basic Windows fundamentals can help you navigate the operating system, install applications and work with command-line tools.
Download the installer from the official Nmap website and follow the installation instructions.
macOS: Nmap can be installed using the official distribution or a supported package manager.
After installation, verify that it works:
nmap --version
This displays the installed Nmap version and related information.
Essential Nmap Commands for Beginners
Start with simple commands in a local lab or on systems you own.
Scan a Local Host:
nmap 127.0.0.1
This scans the local machine and checks commonly scanned TCP ports.
Discover Active Hosts:
nmap -sn 192.168.56.0/24
The -sn option performs host discovery without conducting a port scan. Replace the example network with the subnet assigned to your authorized lab.
Scan Specific Ports:
nmap -p 22,80,443 127.0.0.1
The -p option specifies which ports to examine. This example checks three commonly used ports on the local machine.
Detect Service Versions:
nmap -sV 127.0.0.1
The -sV option attempts to identify services and their versions on discovered open ports.
Version detection can help administrators identify software that may require updates. However, results are not always exact and should be verified.
READY TO GO BEYOND BASIC NETWORK SCANNING?
You’ve learned how Nmap helps discover live hosts, identify open ports and detect running services. Now take the next step and explore how ethical hackers use network discovery and enumeration techniques to assess real-world network security.
Get access to Hackercool Magazine and six beginner-friendly Foundation PDFs designed to help you build essential cybersecurity skills.
YOUR INTRODUCTORY TRIAL INCLUDES:
Networking Fundamentals
Linux Fundamentals
Windows Fundamentals
Web Fundamentals
Command Line Essentials
Virtual Labs
$1 INTRODUCTORY TRIAL
Trial terms apply. Post-trial subscription billing is manual.
Detect the Operating System:
sudo nmap -O 127.0.0.1
The -O option attempts to identify the target operating system using network characteristics. It may require elevated privileges and can be less reliable when network conditions limit the available information.
These commands introduce the core capabilities of Nmap. Always use them only against systems you own or have explicit permission to assess.
Understanding Nmap Scripting Engine (NSE)
Nmap includes the Nmap Scripting Engine, commonly called NSE. NSE allows Nmap to use scripts to perform additional network discovery and assessment tasks.
Scripts can help with:
- Service information gathering.
- Network discovery.
- Configuration checks.
- Identifying certain known vulnerabilities.
- Collecting additional information about supported services.
NSE scripts are organized into categories, including default, discovery, safe, vuln and others.
Not all scripts are equally suitable for every environment. Some can generate significant traffic or affect services. Beginners should understand what a script does before running it and use appropriate scripts only within an authorized scope.
Saving and Understanding Nmap Results
A scan is more useful when its results are recorded and documented. Nmap supports several output formats.
Normal output:
nmap -oN scan-results.txt 127.0.0.1
XML output:
nmap -oX scan-results.xml 127.0.0.1
Multiple output formats:
nmap -oA lab-scan 127.0.0.1
The -oA option saves results in multiple formats using the specified filename prefix.
When reviewing results, record the target, scan date, discovered hosts, port states, identified services and any limitations. This makes it easier to compare results during later assessments.
Nmap can generate scan results in several formats that can be used for further analysis. Beginners who want to automate security tasks can also learn Python for ethical hacking to process scan output, extract useful information and build simple security automation scripts.
Beginner Nmap Lab: Discover Your Local Network
You can practise Nmap using an isolated virtual network that you control.
Objective: Identify active hosts and examine services in a safe lab.
Requirements:
- Nmap installed on your computer.
- A virtual machine or another lab device.
- A private virtual network configured for the exercise.
- Permission to examine every device in the lab.
Exercise 1: Identify your lab network
Review the network configuration of your virtual machine and identify its assigned IP address and subnet.
Exercise 2: Discover active hosts
Use Nmap’s host discovery option to identify responding devices within your authorized lab subnet.
Exercise 3: Examine open ports
Choose one lab machine and scan selected ports. Record which ports are open, closed or filtered.
Exercise 4: Identify services
Use service detection to examine the applications associated with open ports. Compare the results with the services configured on the lab machine.
Identifying open ports is only the first step in network discovery. Nmap can also help identify the services running on those ports, including web servers and other applications. Understanding web server security is important because exposed or misconfigured services can create security risks for an organization.
Exercise 5: Document your findings
Prepare a short report containing:
- Lab environment and objective.
- Network range examined.
- Commands used.
- Active hosts discovered.
- Open ports and identified services.
- Observations and security recommendations.
Do not scan public IP addresses, third-party networks or devices outside your authorized scope.
After completing this Nmap lab, consider documenting the steps you followed, the commands you used, your scan results and what you learned. Adding practical projects such as this to your cybersecurity portfolio can help demonstrate your technical skills and learning progress to potential employers.
How Nmap Helps Ethical Hackers
Nmap is useful during the reconnaissance and network discovery stages of an authorized security assessment. It helps testers understand the target environment before investigating individual services. For example, discovering an exposed service may lead an assessor to review its configuration, software version and access controls.
Network discovery is useful in different cybersecurity roles. Red Team professionals may use Nmap during authorized reconnaissance while Blue Team professionals can use network discovery to understand their environment and identify unexpected devices or exposed services. Learn more about the differences between Red Team and Blue Team roles in cybersecurity.
However, Nmap does not automatically determine whether a system is vulnerable. Its results need to be interpreted alongside configuration reviews, service documentation and other assessment evidence.
Conclusion
Nmap is an essential tool for learning network discovery and security assessment. Its ability to identify active hosts, examine ports, detect services and collect network information makes it valuable for both administrators and ethical hackers.
Beginners should start with basic scans, learn how to interpret results and practise in isolated labs. As your networking knowledge improves, you can explore more advanced Nmap features and use your findings as part of a documented cybersecurity portfolio.
READY TO TAKE YOUR FIRST STEPS TOWARDS NETWORK SECURITY?
You’ve explored how Nmap helps ethical hackers discover network devices, examine open ports and understand the services running across a network.
Now build the foundational knowledge you need to explore network security and ethical hacking further.
Download the Beginner Ethical Hacker Starter Kit and start developing the essential skills every aspiring ethical hacker needs.
















