6 Nmap Scans I Actually Use
One of the things I find particularly interesting about cybersecurity is how quickly a seemingly simple question can lead to a much deeper investigation. What devices are connected to my network? What services are they
One of the things I find particularly interesting about cybersecurity is how quickly a seemingly simple question can lead to a much deeper investigation.
What devices are connected to my network? What services are they running? Why is that particular port open? Is it supposed to be?
These are straightforward questions, but answering them properly requires more than simply opening your router's administration interface and looking through a list of connected devices.
This is where Nmap comes into its own.
Nmap (Network Mapper) is an incredibly powerful open-source tool for network discovery and security auditing. Its flexibility is one of its greatest strengths, but it can also make it somewhat intimidating for someone just beginning their cybersecurity journey. Opening the manual page for the first time can leave you wondering where on earth to start.
While developing my Nmap Recipe Pack, I spent time running different scans against devices and virtual machines within my own home lab. What became increasingly apparent was that, despite the enormous number of options available, I kept returning to the same handful of commands.
Not because they were particularly sophisticated, but because they answered the questions I was actually asking.
In this article, I want to share six of those commands, explain why I use them, and explore some of the things you can learn from their results.
Whether you're studying for CompTIA Security+, building your first cybersecurity home lab, or simply interested in understanding what's happening on your own network, these scans provide a practical starting point.
Before We Begin: Permission Matters
Before discussing individual commands, it's worth establishing an important principle of cybersecurity: having the technical ability to do something does not automatically give you permission to do it.
Network scanning should only be conducted against systems you own or have explicit authorisation to test, preferably in writing.
A home network, a collection of virtual machines, or a purpose-built cybersecurity lab provides an excellent environment for developing these skills. Scanning your employer's infrastructure, a neighbour's network or randomly selected public IP addresses without permission is another matter entirely.
A good cybersecurity practitioner develops professional and ethical habits alongside technical skills.
Throughout this article, I'll use the following example addresses:
- Network range:
192.168.1.0/24 - Individual host:
192.168.1.10
You will need to substitute these with the appropriate addresses from your own authorised testing environment.
1. Discovering What's on My Network
Host discovery
nmap -sn 192.168.1.0/24
Before investigating individual devices, I generally want to establish what is present on the network in the first place.
It sounds obvious, but one of the fundamental challenges of cybersecurity is that you cannot effectively protect assets you don't know exist.
Modern household networks can contain a surprising number of devices. Computers, mobile phones, televisions, printers, smart appliances, security cameras, virtual machines and networking equipment may all be communicating across the same infrastructure.
The -sn option instructs Nmap to perform host discovery without proceeding to a port scan.
Rather than investigating which services are running on each device, Nmap attempts to determine which hosts are reachable.
This makes it a useful first step when exploring an unfamiliar network or establishing a baseline of known devices.
What can we learn?
Host discovery can help identify:
- Active devices within a network range.
- Unexpected or unfamiliar devices.
- Changes in network membership over time.
- Potential targets for further authorised investigation.
However, the absence of a device from the results does not necessarily mean that the device is offline. Firewalls, network configurations and differences in how devices respond to discovery probes can all influence the results.
This introduces an important lesson that applies to almost everything we do with Nmap: scan results represent observations, not necessarily absolute truths.
Nmap reports what it can determine under the conditions in which the scan was performed.
Understanding those conditions is part of understanding the results.
2. Getting a Quick Overview of a Device
Fast port scanning
nmap -F 192.168.1.10
Once I've identified a device that I want to investigate, my next question is usually a simple one.
What is listening for incoming connections?
Computers and network-connected devices communicate through ports. Different applications and services listen on these ports, allowing other systems to establish connections with them.
For example, a web server might listen on TCP port 80 or 443, while an SSH server commonly listens on TCP port 22.
By default, Nmap scans the 1,000 most commonly encountered ports for the selected protocol. The -F option reduces this to approximately 100 commonly encountered ports, making the scan considerably smaller.
I find this particularly useful when I want an initial impression of a device without immediately committing to a comprehensive investigation.
Why not scan everything straight away?
There is a temptation, particularly when learning cybersecurity, to reach for the most comprehensive command available.
However, more information is not always better information.
A smaller, focused scan can provide enough context to determine whether a deeper investigation is worthwhile. It can also make the results easier to understand, especially when you're still learning what different network services do.
The trade-off, of course, is coverage. Services operating on less common ports may not appear in the results.
A fast scan is therefore a starting point, not a definitive assessment of a device's exposed services.
3. Finding Out What's Actually Running
Service and version detection
nmap -sV 192.168.1.10
Discovering an open port is useful, but knowing that a port is open only answers part of the question.
What application is actually listening on it?
Consider a device with TCP port 8080 open. The port is commonly associated with HTTP-related services, but its number alone does not establish whether we're looking at a web application, a development server, a management interface or something else entirely.
Port numbers are conventions, not guarantees.
The -sV option instructs Nmap to perform service and version detection. Nmap sends additional probes to discovered services and analyses their responses to identify the software that may be running.
Where possible, it also attempts to determine the software version.
Why version information matters
From a defensive cybersecurity perspective, service identification can be considerably more valuable than port identification alone.
Knowing which software is running may allow you to:
- Identify outdated applications.
- Investigate publicly documented vulnerabilities.
- Discover services that are no longer required.
- Verify that installed software matches expectations.
- Make more informed patching and hardening decisions.
For instance, identifying an SSH server is useful. Identifying the implementation and apparent version provides additional information that can be investigated.
There is an important distinction here, however.
An older software version does not automatically mean a system is vulnerable. Some operating systems and software vendors backport security fixes without changing the main version number.
Equally, a service may provide incomplete or misleading version information.
Service detection gives us a valuable starting point for further research, but it does not replace that research.
This is where cybersecurity begins to move beyond running tools and into interpreting evidence.
4. Gathering More Context with Default Scripts
Service detection and the Nmap Scripting Engine
nmap -sC -sV 192.168.1.10
If I had to select just one of these commands for general-purpose investigation within my own lab, this would probably be it.
It combines service and version detection with Nmap's default selection of scripts through the Nmap Scripting Engine, commonly referred to as NSE.
The -sC option enables the default script set, while -sV performs service and version detection.
Depending on the services discovered and the scripts that apply, this combination can reveal information beyond what a conventional port scan provides.
Examples include:
- SSH host key information.
- Web page titles.
- TLS certificate information.
- Supported protocol information.
- Details relating to SMB services.
What I particularly like about this scan is that the additional information often provides context that a simple list of open ports cannot.
Moving from discovery to understanding
Imagine discovering a Windows computer with TCP port 445 open.
Knowing that SMB is available is useful, but it immediately raises further questions.
Is the service required? Is it configured appropriately? What protocol versions are supported? Is access restricted to the systems that actually need it?
These are the sorts of questions that make network enumeration interesting.
The purpose isn't necessarily to find something vulnerable. Sometimes the most valuable outcome is simply discovering that a system has been configured exactly as intended.
Other times, you may discover that a service has remained enabled long after its original purpose disappeared.
It is also worth remembering that NSE scripts interact with applications and services. Some default scripts may be intrusive, and their activity can be recorded by monitoring systems.
As with any security tool, understanding what you're running is preferable to blindly trusting its defaults.
5. Looking Beyond the Common Ports
Full TCP port scanning
nmap -p- 192.168.1.10
One of the limitations of the previous port scans is that they examine only a subset of the available ports.
While this is often sufficient for an initial assessment, applications do not have to operate on their conventional port numbers.
A developer might configure a web application on an unusual port. A database may have been configured with a non-standard listening port. A forgotten application could be running somewhere outside the range covered by a conventional scan.
The -p- option instructs Nmap to scan all TCP ports from 1 through to 65,535 when used with its usual TCP scanning behaviour.
This provides substantially broader coverage of a device's accessible TCP ports.
Why this matters
One of the misconceptions sometimes encountered in cybersecurity is that moving a service to an unusual port makes it secure.
Changing the listening port may reduce some opportunistic connection attempts, but it does not provide meaningful protection against someone capable of discovering open ports.
A service running on TCP port 54321 still needs appropriate authentication, access controls and security updates.
Its unusual port number does not change those requirements.
Full port scanning is particularly useful when establishing a comprehensive baseline of an individual system or investigating discrepancies between expected and observed services.
However, it takes longer, generates more network traffic and does not automatically identify the applications behind each discovered port.
It also does not examine UDP ports.
Even a scan of every TCP port should not be mistaken for a complete security assessment.
6. Identifying the Operating System
Operating system fingerprinting
sudo nmap -O 192.168.1.10
Another useful piece of information when investigating a network device is the operating system it may be running.
A Linux server, Windows workstation, network router and embedded IoT device may exhibit different characteristics in how they implement and respond to network protocols.
Nmap's operating system detection functionality attempts to identify these characteristics through a technique known as TCP/IP fingerprinting.
It compares observed network responses against a database of known operating system fingerprints and reports possible matches.
On Linux, this generally requires elevated privileges, which is why the example uses sudo.
How reliable is operating system detection?
Operating system fingerprinting is fascinating, but it is also a good example of why security tools should not be treated as infallible.
Firewalls, network address translation, virtualisation and insufficient responses from a target can all influence the accuracy of operating system detection.
Nmap may provide several possible matches or report a result with limited confidence.
I prefer to treat these results as another piece of evidence rather than a definitive identification.
If an operating system fingerprint, service information and known device characteristics all point towards the same conclusion, that conclusion becomes more credible.
This principle extends well beyond Nmap.
Good cybersecurity analysis involves bringing together multiple observations, recognising uncertainty and avoiding conclusions that the available evidence cannot support.
Putting It All Together: Developing a Methodology
Learning individual Nmap commands is relatively straightforward. Developing an understanding of when and why to use them takes more practice.
Rather than thinking about these six commands as independent recipes, I prefer to think of them as a collection of tools that answer different questions.
| Question | Nmap command |
|---|---|
| What devices are reachable on my network? | nmap -sn |
| What common ports are exposed? | nmap -F |
| What services are running? | nmap -sV |
| What additional information can I gather? | nmap -sC -sV |
| Are there services on less common TCP ports? | nmap -p- |
| What operating system might the device be running? | nmap -O |
Not every investigation requires every scan.
Sometimes a host discovery sweep is all that's needed. Other situations warrant a more detailed examination of a particular device.
The important thing is to have a reason for performing each scan and to understand what you intend to learn from its results.
Running a command because it looks impressive teaches considerably less than running a command because you have a specific question you want answered.
Don't Forget to Save Your Results
One of the habits I would encourage anyone learning cybersecurity to develop early is documenting their work.
Running a scan, reading the output and closing the terminal might satisfy your immediate curiosity, but it leaves you with little to refer back to later.
Nmap provides a convenient way to save scan results using the -oA option.
nmap -sC -sV -oA lab-scan 192.168.1.10
This saves the results in three formats:
| File | Purpose |
|---|---|
lab-scan.nmap |
Human-readable scan results |
lab-scan.gnmap |
Grepable output for simple text processing |
lab-scan.xml |
Structured output for programmatic processing and compatible tools |
Maintaining a collection of previous scan results allows you to establish a baseline and identify changes over time.
Perhaps a service has appeared that wasn't present last month. Perhaps a software update has changed the reported version of an application. Perhaps a service that should have been disabled is still listening for connections.
Without historical information, those changes can be difficult to identify.
Documentation is also valuable when completing cybersecurity labs, writing technical reports or simply revisiting something you didn't fully understand the first time.
Your scan results become a record of both your network and your learning.
Remember to store them securely, as scan output can contain sensitive information about your infrastructure.
Try It Yourself
If you're just beginning to explore Nmap, I would suggest starting with a small experiment on your own authorised network.
Choose a device you're already familiar with, preferably a computer or virtual machine you control.
Before running a scan, write down which network services you expect to find.
Then perform a fast port scan, followed by service and version detection.
Compare your expectations with the results.
Were there services you didn't anticipate? Were any expected services missing? Can you explain why each discovered port is open?
Resist the temptation to move immediately to the next command. Spend some time researching the unfamiliar results.
That process of forming an expectation, gathering evidence and investigating discrepancies is a valuable skill that extends into almost every area of cybersecurity.
You may find that understanding the results of one scan teaches you considerably more than running twenty scans you barely understand.
Final Thoughts
Nmap is often associated with penetration testing, but I think that association can sometimes overshadow its value as a defensive security and educational tool.
You don't need to be attempting to exploit a system to benefit from understanding how it communicates, what services it exposes and how its configuration changes over time.
For me, much of the enjoyment of learning cybersecurity comes from developing a better understanding of technology that I have been using for years.
A computer that previously appeared to be little more than an IP address on a network gradually becomes a collection of identifiable services, protocols, applications and configurations.
Each scan reveals another part of that picture.
The six commands covered in this article barely scratch the surface of what Nmap can do, but they provide a foundation that can support considerably more advanced learning.
And a solid understanding of the fundamentals will always be more valuable than an extensive collection of commands you don't fully understand.
Take Your Nmap Learning Further
While developing my own understanding of Nmap, I began compiling a collection of practical, repeatable commands that I could return to whenever I needed them.
That collection became the Nmap Recipe Pack.
Rather than simply reproducing information from the Nmap manual, the pack focuses on practical applications, with lab-tested commands, actual scan output and explanations of when and why particular options are useful.
It covers network discovery, service enumeration, scripting and scan output, with the aim of helping readers develop an understanding of both the commands and the information they produce.
Whether you're working towards a cybersecurity certification, experimenting within a home lab or developing your network security skills, it is designed to be a practical companion to your learning.
Stay curious. Keep learning. Understand the tools you use.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.