Finding Spies in Local Network with NMAP
Name: Magistr90 Contacts: kvarnali@mail.ru About: I started learning Linux on my own by reading literature, and once I mastered the basics I enrolled to study as a sysadmin, but there I quickly realized that books are far more productive and enjoyable than the stuffy lectures of incompetent specialists) Links:
Greetings!

A familiar situation: you come to work in the morning, and something strange is happening in the network. Some “rogue” device has sneaked into the subnet, or a web server stopped listening on port 443 after an update.

Or maybe you just want to know what your servers are breathing and whether it’s time to update the software before the bad guys do it for you. For all this, there is Nmap - a real Swiss army knife for network reconnaissance.

Introduction

Nmap (Network Mapper) - a utility for network scanning and security analysis, originally developed by Gordon Lyon (known under the pseudonym Fyodor) and first released in September 1997 as an article and source code in the Phrack magazine. Initially, nmap was a simple port scanning tool for Linux, but over time it has evolved into a cross-platform open-source project that supports different platforms.

Today, nmap is one of the most common tools in the arsenal of system administrators and information security specialists.

What Nmap shows

All this is done from the terminal, quickly and without unnecessary noise.

Why you need this as a specialist

If you are an admin, I think I don’t need to explain, but just in case:

  1. Network inventory. You will be surprised how much is actually hanging around in your local network. Especially in companies where “everything is supposedly recorded”.
  2. Searching for unauthorized devices. Someone plugged their router into an outlet in the next office? Nmap will expose it.
  3. Checking service availability. After deployment or server restart - quickly verify that the required ports are open and listening.
  4. Problem diagnosis. If a host doesn’t respond to ping, but is physically on the network - Nmap will help you understand what’s going on.
  5. Security checks. Open ports are a potential attack vector. Informed - means armed.

Installing Nmap

On Linux (Ubuntu/Debian) it installs in two commands:

BASH
sudo apt update
sudo apt install nmap
Click to expand and view more

Check:

BASH
nmap --version
Click to expand and view more

Version is in place - excellent, let’s work.

Working with Nmap

First scan: let’s see who’s in the network

Take your local subnet. Usually it’s 192.168.1.0/24 or 192.168.0.0/24. Let’s run:

BASH
nmap 192.168.1.0/24
Click to expand and view more

Nmap will poll all subnet addresses and show who responded. The output will look something like this:

That’s the whole picture.

Quick scan of a single host

You don’t always need to run through all 65535 ports. Sometimes a quick look at the top 100 is enough. For this - the key -F:

BASH
nmap -F 192.168.1.7
Click to expand and view more

We save time and don’t strain the network unnecessarily.

Full analysis: “know-it-all” mode

If you need maximum information about a device - use -A. It includes OS detection, service version detection, and runs standard security scripts.

BASH
nmap -A 192.168.1.7
Click to expand and view more

Scanning specific ports

When you know exactly which ports you’re interested in (for example, 22, 80, 443), just list them:

BASH
nmap -p 22,80,443 192.168.1.7
Click to expand and view more

Useful after changing configuration - quickly check if the services are alive.

Operating system detection

OS detection requires root privileges:

BASH
sudo nmap -sS -O 192.168.1.0/24
Click to expand and view more

In the results you will see assumptions like Linux 2.6.32 or Windows 10. An old OS is a reason to think about update policy.

Scan speed: don’t push the horses

Keys -T0 - -T5 control the intensity:

For everyday work, -T4 is enough:

BASH
nmap -T4 192.168.1.6
Click to expand and view more

Service version detection

The -sV key shows what exactly program is listening on the port. Instead of http you will see nginx 1.18.0 or OpenSSH 8.9. This is critical for risk assessment: outdated software is known vulnerabilities.

BASH
nmap -sV 192.168.1.6
Click to expand and view more

If the host is “silent” on ping: the -Pn key

It happens that a device or firewall ignores ICMP requests. Nmap might think the host is inactive and skip it. In such cases, use -Pn - Nmap immediately begins scanning, skipping the availability check:

BASH
nmap -Pn 192.168.1.1
Click to expand and view more

Saving results

To save a report use -oN (text file):

BASH
nmap -oN output.txt 192.168.1.1
Click to expand and view more

Or -oX for XML - convenient for automation and parsing.

Quick reference for keys

Save the table so you don’t have to keep it all in your head:

KeyDescription
-sSSYN scan (stealth mode). Requires root.
-sTFull TCP connection. Works without root.
-sVService version detection.
-OOperating system detection.
-sCRunning standard NSE scripts (vulnerability checks).
-AAdvanced mode: -sV + -O + -sC.
-PnSkip host availability check (if it doesn’t respond to ping).
-p 80,443Scan only specified ports.
-p-Scan all 65535 ports.
-FFast scan (only 100 popular ports).
-T0..-T5Speed level: from 0 (very slow) to 5 (aggressive).
-oN file.txtSave result to text file.
-oX file.xmlSave result to XML.
-vVerbose output.
--openShow only open ports.
--top-ports 100Scan a specified number of most popular ports.

Complex command (all in one)

Let’s put it all together. Let’s say you need to quickly and thoroughly scan a host:

BASH
sudo nmap -T4 -sV -O -Pn -oN results.txt 192.168.1.1
Click to expand and view more

Breakdown:

You get the full picture and don’t lose data.

A couple of tips

Nmap is an indispensable tool in any administrator’s toolkit. It helps you keep your finger on the pulse of your network, find problems, and prevent attacks. The main thing is to use it wisely and within the law.

If you like these kinds of manuals, I publish short versions on Linux and system administration in my Telegram channel Linux for Admins and DevOps. I’ll be glad to see colleagues in my channel, come join!

Comments

Copyright Notice

Author: Magistr90

Link: https://r4ven.me/en/vychislyaem-shpionov-v-lokalnoy-seti-s-pomoshchyu-nmap/

License: CC BY-NC-SA 4.0

Blog materials may be used with attribution to the author and source, for non-commercial purposes, and under the same license.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut