BLOG

NMAP Network Scanning: a complete guide for beginners

nmap network scanning

Network security is one of the fundamental pillars of information technology and efficient tools are essential for identifying and mitigating vulnerabilities. Within this reality, NMAP (Network Mapper) stands out as one of the most influential and versatile network scanning tools.

It is a resource used by system administrators, security professionals, and technology enthusiasts to obtain a detailed overview of network traffic and possible threats. Are you one of these people and want to understand NMAP Network Scanning better? Read on to understand how it works, its usability, and more!

What is NMAP?

NMAP (Network Mapper) is an open-source tool widely used for network scanning and security auditing. Created by Gordon Lyon in the late 1990s, it emerged as a solution to the growing need for system administrators and security experts to monitor networks and identify possible vulnerabilities effectively.

Originally, NMAP was developed for Unix environments, but due to its popularity and efficiency, it is now compatible with various operating systems, including Windows and macOS. In addition, the tool has gained new features over the years and has established itself as one of the most widely used pieces of software in the cybersecurity field.

As a key differentiator, the scanner is extremely versatile. It can scan entire networks, and identify which devices are active, which ports are open, and which services are running. This makes it essentia for security tests and for diagnosing corporate and home networks.

In addition, the tool is widely used in penetration tests, security audits, and digital forensic investigations. IT professionals and enthusiasts can use NMAP to understand the infrastructure of their networks better and ensure that they are properly protected against cyber threats.

How to install NMAP?

NMAP is available for several operating systems. To install it, follow the steps below according to your system:

Windows: 

  1. Download the installer from the official website: https://nmap.org/download.html.
  2. run the installer and follow the on-screen instructions. 
  3. After installation, open the Command Prompt and type Nmap to check the installation’s success.

Linux (Ubuntu/Debian): Run the following command in the terminal: sudo apt update && sudo apt install nmap -y

macOS: If you use Homebrew, install with: brew install nmap.

What is NMAP used for?

NMAP is a powerful and versatile tool, mainly used for mapping networks and detecting possible vulnerabilities. One of its most common functions is host discovery, allowing network administrators to identify which active devices are within a given environment. This is useful for managing large infrastructures and ensuring all connected devices are legitimate.

Another critical application is service identification, which checks which ports are open and which services are running on a device. This helps with the configuration and maintenance of servers, making it possible to identify unnecessary or vulnerable services that could pose a risk to network security.

In addition, the tool makes it possible to check software versions, allowing users to determine which operating systems and application versions are running. This makes it easier to update and maintain software, preventing attacks based on outdated versions or those with known flaws.

In the security field, NMAP is widely used for vulnerability analysis, helping cybersecurity professionals identify possible loopholes before they are exploited by attackers. It can be used to test systems for common flaws, helping to implement corrective measures.

Finally, as mentioned above, it can be used in penetration tests, to simulate attacks and assess the robustness of a network against external threats. In this case, security professionals can use NMAP to conduct detailed audits and strengthen the defenses of critical systems.

How to use NMAP?

Once installed, NMAP can be used for a variety of purposes. Here are some of the most common commands:

  • Discovering devices on the network: nmap -sn 192.168.1.0/24 – This command performs a scan to list all devices connected to a local network.
  • Scan open ports on a host: nmap -p 1-65535 192.168.1.100 – This command checks all ports (1 to 65535) on the device with IP 192.168.1.100.
  • Identify running services and their versions: nmap -sV 192.168.1.100 – This command displays which services are running and their versions.
  • Identify operating system: nmap -O 192.168.1.100 – With this command, NMAP tries to identify which operating system is being used by the host.
  • Perform an aggressive scan: nmap -A 192.168.1.100 – Performs a detailed analysis including operating system, service detection, and traceroute.

How do I use scripts with NMAP?

NMAP has a powerful script library called NSE (Nmap Scripting Engine), which allows you to run more advanced tests, such as vulnerability detection.

  • Scan for known vulnerabilities: nmap –script=vuln 192.168.1.100 – This command uses scanning scripts to identify vulnerabilities on the specified host.
  • Scan for open ports with scripts: nmap -sC 192.168.1.100 – This command runs standard scripts to gather additional information about the target.

Best practices for using NMAP safely

Although NMAP is a handy tool for analyzing and monitoring networks, its improper use can cause legal and technical problems. It is therefore essential to adopt good practices when using it. 

Make sure you have permission to scan a network, as scanning systems without authorization can be considered an illegal activity in many jurisdictions. In addition, it is best to segment your analysis, avoiding scanning large blocks of IPs at once, which can raise suspicions and result in blocks by firewalls and intrusion detection systems (IDS).

Another important aspect is analyzing security logs. Many firewalls and IDSs are configured to detect scans made by NMAP, which can block access or alert network administrators. 

Monitoring and interpreting these logs helps to adjust scan settings to avoid unnecessary blocks and obtain more accurate results. In addition, keeping NMAP up to date is essential to ensure support for the latest scanning techniques and network protocols.

Correctly interpreting the results is also an essential skill for using NMAP effectively. The tool classifies ports into different states: 

  • Open, when the port is active and accepting connections;
  • Closed, indicating that the port is not in use, but can be opened in the future; 
  • Filtered, when a firewall prevents direct verification of the port;
  • Unfiltered, which means that the port is accessible, but its status could not be determined; 
  • Open|Filtered, when NMAP can’t define whether the port is open or filtered due to a lack of response from the host. 

Understanding these classifications allows network administrators to make strategic security and service configuration decisions.

It is worth adding that the Nmap Scripting Engine (NSE) allows users to carry out more advanced analysis, using pre-configured scripts for specific tasks, such as vulnerability detection and service analysis. 

With NSE, you can run commands such as nmap –script=vuln 192.168.1.100, which checks for known vulnerabilities on the specified host, or nmap -sC 192.168.1.100, which runs standard scripts to gather detailed information. 

Types of Scans in NMAP

NMAP offers different scan types, each suitable for various network analysis scenarios. Some of the main types include:

  • SYN Scan (-sS): also known as a “stealth scan”, this is one of the most common and fastest. It does not complete the TCP connection, making it less detectable by firewalls.
  • UDP Scan (-sU): scans UDP ports to find services such as DNS and DHCP, wich are essential for identifying services that don’t use the TCP protocol.
  • Xmas Scan (-sX): sends packets with unusual TCP flags to identify filtered and closed ports, wich are useful for analysis on networks protected by firewalls.
  • Idle Scan (-sI): one of the most secretive, it uses an intermediate host (zombie) to perform the scan without revealing the scanner’s IP address.

Each mode can be used depending on the level of secrecy and depth of analysis desired.

Conclusion

This software is mainly recommended for network administrators and security professionals, as it allows them to map networks and identify vulnerabilities efficiently. It should be used responsibly, respecting the laws and guidelines of each country. 

This guide will help you explore the tool and improve your understanding of network security. To deepen your knowledge, consult the official NMAP documentation at https://nmap.org/book/man.html.