If you’re looking for a free network discovery tool, you’ve probably heard of Nmap.
Nmap, short for Network Mapper, is a multi-purpose tool commonly used for penetration testing to give you a granular view of your network’s security.
Its capabilities extend to collecting information and enumeration and detect vulnerabilities and security loopholes. You can also use the tool to find live hosts on a network, perform operating system (OS) detection, traceroute, version detection, ping sweeps, and carry out port scanning. Precisely why Nmap is also known as the sysadmin’s Swiss Army knife.
To learn about what Nmap is and how to use it to secure your network, read on.
Nmap is a network scanning tool—an open source Linux command-line tool—used for network exploration, host discovery, and security auditing. Gordon Lyon (pseudonym Fyodor Vaskovich) created it to help map an entire network easily and find its open ports and services.
In other words, you can use Nmap to scan IP addresses, search for security loopholes, and scan for open ports on your computer network by sending packets and analyzing the responses.
Remember your favorite scene from The Matrix when Trinity managed to exploit a vulnerable SSH server? She used Nmap to work her magic.
At its core, Nmap uses IP packets to give you detailed, real-time information on all your networks, as well as the devices (servers, routers, switches, mobile devices) connected to them.
Here’s a breakdown of the primary use of Nmap:
Although Nmap was developed for enterprise-scale networks, smaller companies are using the tool to scan connected devices. The exceptional rise of the IoT, in particular, has accelerated the increasing adoption of the tool to ensure top-notch data security.
Nmap uses diverse techniques to scan, such as TCP connect scan, TCP SYN scan, TCP reverse ident scan, FTP bounce scan, and so on. Each of these methods has its own benefits and drawbacks, and whether you should opt for simple scanning or advanced scanning depends on the target machine.
Before you get started with Nmap, the software needs to be installed.
The installation process is easy, but it may vary based on your operating system. Below, we’ve covered how to install an app for Windows, MacBook, and Linux versions.
We can't set up a Nmap tutorial without outlining its commands. Here's a quick rundown of some common functions of Nmap you can try:
A ping scan returns information on every IP active on your network.
You can use the following command to execute a ping scan:
> nmap -sp 192.168.1.1/24
Note: You can run a Scan a Single Host command to scan a single host for 1000 well-known ports—ports that are used by popular services like SQL, SNTP, and apache.
Here's how to run this command:
> nmap scanme.nmap.org
There are tons of ways to execute a scan for ports. The main differences between the varying types of port scans are whether they cover TCP or UDP ports and if they run a TCP connection.
For instance, the TCP Connect scan actively queries every host and requests a response, while the UDP scan uses UDP packets to scan DNS, SNMP, and DHCP ports to do the same job.
Let's review the different port scanning types below.
> nmap -p 973 192.164.0.1
> nmap -p T:7777, 973 192.164.0.1
> nmap -p 76–973 192.164.0.1
> nmap --top-ports 10 scanme.nmap.org
Host scanning gives you detailed information on a specific host or a range of IP addresses, including their latency, MAC address, and any description associated with that address. In turn, this will allow you to quickly identify and eliminate suspicious hosts connected to your network.
You can use the following commands to execute a host scan:
> nmap 192.164.1.1 192.164.0.2 192.164.0.2
> nmap 192.164.1.*
> nmap 192.164.0.1,2,3,4
> nmap 192.164.0.0–255
Note: If you want to scan a hostname, you simply have to replace the IP address for the host.
Nmap can also provide operating system detection, script scanning, version detection, and traceroute. In fact, OS scanning is claimed as one of the most powerful features of the tool.
OS scanning involves Nmap sending TCP and UDP packets to a particular port before analyzing its response. This scan then compares the response to a 2600-strong operating systems database and returns information on a host’s OS (and version).
You can use the following command to execute an OS scan:
> nmap -sV scanme.nmap.org
Disclaimer: OS detection may not always be accurate. Still, it does a fairly good job at getting a pen tester closer to their target.
Running a stealth scan involves analyzing the response after sending an SYN packet. If SYN or ACK is received, it indicates the port is open, and you can open a TCP connection.
Keep in mind that a stealth scan never completes the 3-way handshake, so the target may face difficulty determining the scanning system.
Use the following command to run a stealth scan:
> nmap -sS scanme.nmap.org
As the name suggests, this command auto-scans several 'most popular' ports of a host. This can come in handy for users who run Nmap on a home server.
You can use the following to execute this Nmap command:
> nmap --top-ports n 192.168.1.106
Replace the ‘n’ in the above command for the number of ports you want to scan. Nmap will quickly scan that many ports.
You can add an extension to your commands if you want to output your Nmap scan results to a file.
Use the following command:
You can use this Nmap command to accelerate your Nmap scan using the -n parameter, which may disable reverse DNS resolution. We highly recommend this when starting Nmap scanning for a large network.
Let us explain how this Nmap command works using an example.
Suppose you want to turn off DNS resolution for the basic ping scan. To do this, you’ll have to add -n.
Here’s how you can run the command:
> nmap -sp -n 192.100.1.1/24
Learning Nmap can significantly amp up your network security, more so when used alongside other cybersecurity tools.
It assures you a quick, efficient way to perform frequent network audits that keeps hackers at bay while simultaneously improving your knowledge about your own network. You can also scan and uncover essential information concerning your host, ports, firewall, and OS, which can help network administrators do their job more effectively.
Take immediate steps to strengthen your network security posture as a whole. Click here for a free UpGuard trial today!