Planning Scans That Don't Break Things
Scanning is the first step of a test that the client's systems really feel. Most systems shrug it off. Some don't: an old printer that reboots when probed on an unusual port, a building-management controller that locks up under a few hundred connections, a licence server that counts every TCP connection as a session, an application whose log disk fills with junk requests. A scan that takes down a production line ends the engagement and may end the business relationship. Planning a scan means estimating its load and duration, choosing what not to scan, and fitting it into the window with room to stop.
The scan types themselves (connect, SYN, UDP, version detection) and their noise are explained from the defender's side in Network Security; Nmap Connect Scans on Loopback shows the mechanics. This lesson is about the plan.
What makes a scan disruptive
| Factor | Why it hurts | Control |
|---|---|---|
| Rate | many probes per second exhaust connection tables of small devices and firewalls | --max-rate, --scan-delay, timing templates -T2/-T3 |
| Parallelism | many hosts at once multiply the load on shared links and firewalls | --max-hostgroup, scanning by subnet |
| Port count | -p- on 65,535 ports is 65× the probes of the top 1000 |
top ports first, full range only where needed |
| Version and script probes | -sV and NSE scripts send protocol data (junk to the wrong service), open sessions, sometimes log in |
run them on open ports only, choose scripts by name, never categories like dos, intrusive, brute without written approval |
| UDP | slow and retransmission-heavy; some UDP services react badly to empty probes | short port lists, separate window |
| Fragile targets | printers, IP phones, OT/ICS controllers (PLCs, building management), medical devices, legacy appliances | exclude, or scan with a single connect probe per port at very low rate, with the owner watching |
Estimating load and duration
Before the window opens, compute how many probes a scan sends and how long it takes at the agreed rate. Real scanners adapt their timing, so this is an upper-bound planning tool, not a prediction. The numbers below are for the lab scope.
import math
def plan(hosts, ports, rate, retries=1, version_ports=0, version_probes=10):
probes = hosts * ports * (1 + retries)
probes += version_ports * version_probes # rough: -sV probes per open port
seconds = probes / rate
return probes, seconds
def hm(seconds):
m = math.ceil(seconds / 60)
return f"{m // 60}h{m % 60:02d}m"
window_minutes = 9 * 60 # 08:00-17:00, minus nothing: be pessimistic later
jobs = [ # name, hosts, ports, rate (probes/s), expected open ports for -sV
("top-1000 TCP, servers /26", 62, 1000, 100, 40),
("top-1000 TCP, office /25", 126, 1000, 100, 30),
("all TCP ports, 6 key servers", 6, 65535, 100, 25),
("top-50 UDP, servers /26", 62, 50, 20, 0),
("printers: 4 ports, gentle", 5, 4, 1, 0),
]
total = 0
print(f"{'job':<31} {'probes':>10} {'duration':>8}")
for name, h, p, r, v in jobs:
probes, sec = plan(h, p, r, version_ports=v)
total += sec
print(f"{name:<31} {probes:>10,} {hm(sec):>8}")
print(f"{'total':<31} {'':>10} {hm(total):>8} of a {hm(window_minutes * 60)} window per day")
days = math.ceil(total / (window_minutes * 60 * 0.6)) # use only 60 % of each window
print(f"plan: {days} day(s) of scanning at 60 % window use, leaving time to stop, re-run and analyse")job probes duration
top-1000 TCP, servers /26 124,400 0h21m
top-1000 TCP, office /25 252,300 0h43m
all TCP ports, 6 key servers 786,670 2h12m
top-50 UDP, servers /26 6,200 0h06m
printers: 4 ports, gentle 40 0h01m
total 3h20m of a 9h00m window per day
plan: 1 day(s) of scanning at 60 % window use, leaving time to stop, re-run and analyse
The full-port scan of six servers costs more than the top-1000 scans of 188 hosts together. That is typical, and the reason to choose full ranges only for hosts that matter. The printers' four ports at one probe per second take under a minute, but the slowness is for the printers' sake, not the clock's. With the 60 % rule the scans need a day, and the plan says so in advance instead of discovering it at 16:55.
The scan plan document
For each job, write down before the window opens:
- targets (a file generated from the scope) and exclusions;
- command line, including rate limits and output files (
-oA <name>keeps normal, XML and grepable output); - expected duration and the latest start time that still ends inside the window;
- who watches: the client's technical contact knows the start time and the tester's source address;
- abort: how to stop the job (the terminal, the process id), and what counts as a reason (the stop conditions).
A lab example of one entry:
JOB 2 top-1000 TCP, office /25 window 2026-12-02 08:00-17:00 UTC
targets targets/office.txt (126 hosts, generated from scope v2; printers excluded)
command nmap -sS -sV --top-ports 1000 --max-rate 100 --max-retries 1 \
-iL targets/office.txt --excludefile targets/fragile.txt -oA scans/office-top1000
expected ~43 min; latest start 16:00; source 10.10.0.99
watcher client network team (N. Le), informed 07:50
abort Ctrl-C in tmux window "scan2"; stop if any host or the office firewall degradesHow a disruptive scan is detected
The client sees it first: monitoring alarms for a device that stopped answering, helpdesk calls about printers printing garbage (a printer's raw port 9100 will print whatever arrives), firewall CPU and connection-table graphs, IDS alerts flooding the SOC. The tester sees it in the scan itself: hosts that answered earlier now time out, rising retransmissions, ports flipping from open to filtered. Any of these is a stop condition, not a curiosity.
How it is prevented
Agree rates in the RoE, start with the least intrusive job (a top-ports connect scan of a single subnet) and widen only when it went quietly, keep fragile devices in an exclusion file maintained with the client, run version detection and scripts only against open ports, and schedule the riskiest jobs early in the window with the client's engineer watching. For OT and medical networks, prefer passive discovery (reading the client's switch tables, ARP caches and existing monitoring) over any scan.
Pitfalls
-T5and--min-rateto "save time": they cause the timeouts and missed ports that make the scan worthless, besides the load.- NSE categories instead of names.
--script defaultis reasonable;--script vulnorallruns intrusive checks, some of which can crash services. - Port 9100 on printers. A connect probe followed by version detection can print pages of junk. Exclude 9100 or the printers.
- Forgetting that a NAT gateway or firewall in the path takes the load of every host behind it.
Practice
- Change the full-port job to
rate=300and the office job to two retries. What happens to the total, and which change would you rather not make on a production network? - Write the scan-plan entry for the printers' job, including the exclusions it doesn't need.
Answers
- The full-port job drops from 2h12m to 44m, the office job grows from 43m to 1h04m, and the total falls from 3h20m to 2h14m. A higher rate is the risky change on production; retries add load more gently and improve accuracy on lossy links.
- For example: targets
targets/printers.txt(5 hosts, owner P. Vo watching), commandnmap -sT -p 80,443,515,631 --max-rate 1 --max-retries 0 -iL targets/printers.txt -oA scans/printers(no-sV, and port 9100 deliberately not scanned), window 08:30-09:00, abort on any printer error light or job. It doesn't need the fragile-device exclusion file because it is the fragile list, scanned on purpose and gently.
Test yourself
Which change multiplies the probes of a top-1000 scan by about 65?
- Adding -sV
- Scanning all 65,535 ports with -p-
- Using -T3
- Adding --max-retries 1
A scan of the office range makes three printers print garbage. What is this?
- A finding against the printers
- A stop condition: pause, inform the client, review the plan
- Normal; continue
- A false positive
Which Nmap script selection is acceptable without special written approval?
- --script all
- --script vuln
- A named list of safe scripts such as http-title,ssl-cert
- --script dos
How is discovery best done on an OT or medical network?
- A fast full-port scan
- Passively, from switch tables, ARP caches and existing monitoring, with the owner
- UDP scan only
- Not at all