Nmap — Network Scanning and Host Discovery

Use Nmap only on authorized lab assets to inventory hosts and exposed services.

Est. 20–28 min Updated Suggest a fix
Chapter 1

Inventory Before You Secure

Nmap is a network exploration and security auditing tool. Administrators use it to check their own lab hosts, confirm which services are exposed, and compare observed assets with an approved inventory. A scan sends traffic that may trigger alerts, affect fragile devices, or violate acceptable-use rules. Authorisation must cover the exact addresses, timing, scan type, and rate—not merely the general idea of “testing.”

This lesson stays within loopback and intentionally owned lab targets. Do not point the examples at public addresses, shared networks, or a third party. Do not use stealth, evasion, vulnerability, or exploit scripts. When scope is unclear, stop and ask the asset owner for a written test plan.

Prerequisites: IP addressing, TCP ports, service listeners, and host firewalls. Nmap reports observations from a particular vantage point; it does not provide a complete truth about the target or its security.

Chapter 2

Host Discovery in a Lab

Host discovery asks whether an address appears reachable using probes allowed by the local environment. A host may be active but not respond to a particular probe because of firewall policy, sleep state, or routing. Conversely, an address may answer a probe while the desired application is unavailable. Treat results as evidence with a method and vantage point.

# Restrict discovery to this machine's loopback address
nmap -sn 127.0.0.1

# Read the help/reference for the installed version
nmap --help

The -sn option performs host discovery without a port scan. A single loopback target is a controlled starting point. On shared networks, even discovery probes should be approved and rate-limited according to the organisation's process.


Chapter 3

Ports and Service Inventory

A TCP port can be reported as open, closed, or filtered based on the responses Nmap observes. “Open” means a service accepted or responded to the probe from this location; “filtered” means the probe result was inconclusive due to filtering or lack of response; it does not prove a firewall exists in one specific place. UDP results are often ambiguous because many services do not respond to empty probes.

# Check only a few common ports on loopback, with a connection scan
nmap -sT -p 22,80,443,8080 127.0.0.1

# Add service identification only for the same local target
nmap -sT -sV -p 22,80,443,8080 127.0.0.1

Service detection uses additional probes and can create more traffic. Limit it to a lab host and a small set of ports. Compare the output with the service's own configuration and logs. A banner can be hidden, misleading, or generated by a proxy, so do not equate the reported product name with a verified software version.


Chapter 4

From Findings to a Defensible Change

Suppose an authorised check finds a test web service listening on port 8080. Ask whether it is expected, which process owns it, which interfaces it binds to, and which network policy permits access. If unnecessary, change the service configuration or firewall through the normal review process, then repeat the same narrow scan and confirm expected behaviour. Record the before-and-after results with timestamps.

Network inventory should be reconciled with cloud and endpoint asset systems. A periodic approved scan can reveal unknown devices, but it should use safe rate limits and exclude fragile systems by design. Keep a contact and exception list for systems that cannot tolerate probes.

# Example approved change record
scope: 127.0.0.1 lab VM only
purpose: verify expected test listeners
ports: 22, 80, 443, 8080
window: 2026-11-09 18:00-18:10 UTC
rate: default conservative rate
excluded-assets: none (loopback only)
owner: lab administrator
result-location: restricted incident folder

Chapter 5

Output, Safety, and Limitations

Use normal output for a quick review and choose XML output when an approved inventory pipeline needs structured results. Store scan data carefully because it reveals topology and exposed services. Timestamp runs and preserve the command, scope, tool version, and vantage point so later comparisons are meaningful.

Do not assume OS detection is definitive, that a filtered port is closed, or that one scan reveals all UDP services. Middleboxes, NAT, load balancers, IDS/IPS, rate limiting, and cloud security controls can change what is visible. Avoid aggressive timing and firewall-evasion options; they can disrupt systems and undermine an authorised assessment.

# Save a small local inventory in normal and XML formats
nmap -sT -p 22,80,443,8080 -oN lab-scan.txt -oX lab-scan.xml 127.0.0.1

# Keep outputs private; they may disclose service and host details
Never scan a public range, campus network, employer, cloud tenant, or neighbour's device without explicit written authorisation and an agreed scope. This course does not teach evasion or exploit scanning.

Chapter 6

Mistakes, Practice, and Review

Common mistakes: assuming “filtered” means closed; running broad port ranges by default; trusting version strings as proof; and overlooking the effect of scan timing on fragile devices. Another common error is saving scan output in a public repository or ticket.

Practice: (1) Run the loopback-only discovery command and explain what it can establish. (2) On a local lab VM you administer, compare a small connection scan against its documented listeners. (3) Explain the difference between open, closed, and filtered. (4) Write an approval record for a hypothetical internal inventory scan without running it. (5) Propose a process to reconcile discovered services with an asset inventory.

🎯 Key Takeaways

  • ✓Use Nmap for authorised inventory and auditing, not unsanctioned exploration.
  • ✓A scan reports what probes observed from one vantage point; silence is ambiguous.
  • ✓Open, closed, and filtered describe response evidence, not a complete security judgement.
  • ✓Limit service detection to the agreed lab or asset scope and a small set of ports.
  • ✓Avoid evasion, aggressive timing, and exploit scripts; protect scan output as sensitive inventory.
  • ✓Record authorisation, scope, time, method, owner, and results so findings can lead to accountable changes.

Next: Lesson 44 · Network Monitoring →

HELP US IMPROVE

How was this lesson?

Your note is shared with the Chaduvuko team for review. Please don’t include personal or sensitive information.

Choose your feedback

Spotted a mistake or something unclear? Suggest a fix on GitHub or email us. Select the text first and it is quoted for you.

Share

Discussion

0

Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.

Continue with GitHub
Loading...