Nmap (Network Mapper) is an open-source tool for network discovery and security auditing. Network administrators and security professionals use it to map out networks, identify active devices, detect open ports, and discover services running on those devices. Nmap also supports advanced features such as OS detection, version detection, and scriptable interaction with targets through its NSE (Nmap Scripting Engine), making it essential for vulnerability assessments and penetration testing.
This guide covers two installation methods: the Fedora repository (recommended for most users) and source compilation (for those who need the absolute latest version or custom build options). By the end, you will have Nmap installed and verified, ready for network scanning and security analysis. After installation, you can explore practical scanning techniques in our Nmap commands for beginners guide.
Choose Your Nmap Installation Method
Fedora provides Nmap through its official repositories, and you can also compile the latest version from source. The table below summarizes the key differences to help you decide which approach suits your needs.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| DNF Package Manager | Fedora Repos | Stable (distro-tested) | Automatic via dnf upgrade | Most users who want simple maintenance |
| Source Compilation | Upstream | Latest stable | Manual recompilation | Users needing newest features or custom builds |
For most users, we recommend the DNF method because it provides automatic security updates and integrates with Fedora’s package management system. However, compile from source if you specifically need features unavailable in the repository version or require custom compilation flags.
Method 1: Install Nmap via DNF
The DNF method installs Nmap directly from Fedora’s official repositories. Since Fedora focuses on upstream releases with a six-month release cycle, the repository version is typically recent and well-tested.
Update Fedora Before Nmap Installation
First, update your system to ensure all existing packages are current. This prevents dependency conflicts during installation.
sudo dnf upgrade --refresh
Install Nmap via DNF Command
Next, install Nmap using the dnf install command. DNF automatically resolves and installs required dependencies such as libpcap for packet capture.
sudo dnf install nmap
Verify Nmap Installation
Once installation completes, verify that Nmap is accessible by checking the installed version. This step confirms the package installed correctly and displays the build information.
nmap --version
Expected output (version may vary based on repository updates):
Nmap version 7.92 ( https://nmap.org ) Platform: x86_64-redhat-linux-gnu Compiled with: nmap-liblua-5.3.5 openssl-3.5.x libssh2-1.11.x libz-1.3.x libpcre2-10.x libpcap-1.10.x nmap-libdnet-1.12 ipv6 Compiled without: Available nsock engines: epoll poll select
This output confirms Nmap is installed and displays the libraries included in the build. As a result, you can now use Nmap for network scanning.
Method 2: Install Nmap from Source
Alternatively, compiling Nmap from source gives you access to the latest stable release and allows custom build options. This method requires more steps and manual updates; however, it ensures you have the newest features and security fixes immediately upon release.
Install Build Dependencies
Before compiling, you need to install the required build tools and development libraries. Accordingly, the following commands install the GCC compiler, make utility, and development headers needed for compilation.
sudo dnf install make automake gcc gcc-c++
Next, install the Development Tools group and additional development libraries. Fedora uses lowercase, hyphenated group names for this command.
sudo dnf group install development-tools
sudo dnf install libssh2-devel openssl-devel python3-devel
These packages provide SSL/TLS support, SSH library integration, and Python scripting capabilities for Nmap’s NSE scripts.
Download Nmap Source Archive
Download the latest stable Nmap source code from the official website. At the time of writing, the current stable version is 7.98. If wget is not installed, run sudo dnf install wget first.
cd /tmp
wget https://nmap.org/dist/nmap-7.98.tar.bz2
Check the official Nmap download page for the current version. Replace
7.98in the commands below if a newer version is available.
Extract the Nmap Source Code
After downloading, extract the source archive. The bzip2 -cd command decompresses the archive and pipes it to tar for extraction.
bzip2 -cd nmap-7.98.tar.bz2 | tar xvf -
cd nmap-7.98
Configure the Nmap Build
Run the configure script to prepare the build environment. This script checks for required libraries and creates the Makefile tailored to your system.
./configure
During execution, the configure script produces output showing which features it enables based on available libraries. Therefore, review the summary at the end to confirm the script detects SSL, SSH, and other features.
If configure completes without errors, you will see a summary similar to:
Configuration complete. NMAP ---- nmap: YES ncat: YES nping: YES ndiff: YES (requires python)
Compile Nmap
Now, run the make command to compile Nmap from source. This process reads the Makefile and builds all components. Typically, compilation takes a few minutes depending on your system’s CPU.
make
Additionally, you can speed up compilation on multi-core systems by adding the -j flag followed by the number of CPU cores (e.g., make -j4 for four cores).
Install Nmap Binary
After successful compilation, install Nmap system-wide using make install. This copies the compiled binaries to /usr/local/bin/ and data files to /usr/local/share/nmap/.
sudo make install
Verify Source-Compiled Installation
Finally, confirm that the source-compiled version installed correctly by checking the version. The output should reflect the version you downloaded.
nmap --version
Expected output for version 7.98:
Nmap version 7.98 ( https://nmap.org ) Platform: x86_64-unknown-linux-gnu Compiled with: nmap-liblua-5.4.7 openssl-3.5.x nmap-libssh2-1.11.1 libz-1.3.x libpcre2-10.x libpcap-1.10.x nmap-libdnet-1.14 ipv6 Compiled without: Available nsock engines: epoll poll select
Notice that the source-compiled version shows x86_64-unknown-linux-gnu platform instead of x86_64-redhat-linux-gnu. This difference indicates you built it locally rather than installing from Fedora packages.
Quick Start: Basic Nmap Usage
With Nmap installed, here are a few essential commands to get started. For comprehensive scanning techniques, see our Nmap commands for beginners guide.
Scan a single host:
nmap 192.168.1.1
Scan a network range:
nmap 192.168.1.0/24
Detect service versions on open ports:
sudo nmap -sV 192.168.1.1
The -sV flag performs version detection, identifying specific services and their versions running on discovered ports. Many advanced scans require sudo for raw socket access.
Remove Nmap from Fedora
If you need to remove Nmap, the process depends on how you installed it.
Remove DNF-Installed Nmap
For the package manager installation, use dnf remove to uninstall Nmap. Afterward, run autoremove to clean up orphaned dependencies.
sudo dnf remove nmap
sudo dnf autoremove
The autoremove command removes packages that DNF installed as dependencies but are no longer needed.
Remove Source-Compiled Nmap
For the source-compiled version, remove the installed binaries and data files from /usr/local/. The source installation places files in predictable locations.
Warning: The following commands permanently delete the source-compiled Nmap installation and its data files. This does not affect any DNF-installed version.
sudo rm -f /usr/local/bin/nmap /usr/local/bin/ncat /usr/local/bin/nping /usr/local/bin/ndiff
sudo rm -rf /usr/local/share/nmap
sudo rm -f /usr/local/share/man/man1/nmap.1 /usr/local/share/man/man1/ncat.1 /usr/local/share/man/man1/nping.1 /usr/local/share/man/man1/ndiff.1
Optionally, you can also remove the source build directory if you no longer need it:
rm -rf /tmp/nmap-7.98
Afterward, verify removal by checking that the nmap command is no longer found:
which nmap
If removal was successful, this command produces no output or returns an error indicating the command was not found.
Conclusion
You now have Nmap installed on Fedora, whether through the straightforward DNF package or compiled from the latest source. The DNF method offers simpler maintenance with automatic updates, while source compilation provides immediate access to new features and custom build options. For network security tasks, Nmap’s port scanning, service detection, and scripting capabilities make it an essential tool for discovering what is running on your network and identifying potential vulnerabilities.
I’d just like to thank you for the documentation, and tutorials you have here on your website. Not to mention all the great art as thumbnails, and what not.
😀