masscan

A port scanner for quickly taking inventory of open ports on a network you manage. Use the transmit rate and an exclude list to keep the load down.

cat masscan/meta.ymlChecked on 2026-10-28

Safety

Impact Can harm othersCan do real harm to others: intrusion, tampering, or load
Admin rights
Required
Test lab
Required

Usage

Purpose
Audit
Difficulty
Intermediate
Type
Command line
Platforms
Linux / macOS / Windows

Trust

Repository
robertdavidgraham/masscan
License
CopyleftAGPL-3.0-only
GitHub
stars26,1592026-11-17
Maintenance
Actively updatedLast update 2026-10-05
Contents
  1. Introduction
  2. What masscan does
  3. Network traffic
  4. Transmit rate: the default, and what happens when you raise it
  5. Exclude list: keep devices you must not scan out of the scan
  6. Try it safely: take an inventory of your own range at a low rate
  7. Common options
  8. How masscan differs from Nmap
  9. Cautions
  10. Read next
  11. Sources

This tool can also be used for attacks. Use it only on systems you own or have written permission to test.

masscan is a port scanner that checks a range of IP addresses for open ports very quickly. Its README says it can scan the entire Internet. This review does not cover that. It covers one use: taking a quick inventory of open ports on a network you manage.

Speed is masscan’s selling point. If you raise --rate too far, you load your own line, your routers, and the devices you scan. That is why this review centers on the transmit rate and the exclude list.

This review is for administrators who know the basics of networking (IP addresses and ports). After reading it, you can do the following:

  • Estimate how long a scan takes from the range, the ports, and the transmit rate
  • Write an exclude list that keeps devices you must not scan out of the scan
  • Replace the documentation addresses in the examples with your own range, run an inventory at a low rate, and read the results

What masscan does

  • Open-port detection: It sends TCP SYN packets and reports a port as “open” when a SYN-ACK comes back (from the manual’s description of --show). You can also scan UDP ports, as in -p U:161.
  • Bulk scanning of wide ranges: You combine IP address ranges (CIDR notation and others) with port ranges. IPv6 works with the same command.
  • Saved results: It saves results as XML (-oX), JSON (-oJ), Nmap’s grepable format (-oG), a one-line-per-result list (-oL), or its own binary format (-oB).
  • Pause and resume: When you press Ctrl+C, it saves the state of the scan in paused.conf. Run --resume paused.conf to continue.
What it doesn’t domasscan does not identify software versions or guess the operating system. In the source, the --osscan-limit and --osscan-guess options print an “unsupported” message and exit. To get service details, rescan only the ports it found with Nmap.

Network traffic

  • It sends SYN packets to each address and port in the range you specify, minus the parts you excluded.
  • masscan uses its own TCP/IP stack, separate from the operating system’s. It sends raw packets directly to the network card and receives replies directly.
  • With --banners, it completes the connection and reads the text the service returns (the banner). The steps in this review do not use it.
  • The README and the manual say nothing about traffic to hosts outside the range you give, or about automatic update checks. We did not read the entire source to confirm this.

Transmit rate: the default, and what happens when you raise it

--rate sets how many packets masscan sends per second.

  • The default is 100 packets per second. The README and the manual say so, and the initial value in the source (src/main.c) is 100.0.
  • Fractions are allowed. The manual gives 0.1 (one packet every 10 seconds) as an example.
  • The upper limit depends on your hardware. The official documents give 1.5 to 2.5 million packets per second on Linux without virtualization, and 250,000 to 300,000 on Windows or in a virtual machine. The numbers differ between documents, so treat them as rough figures.
  • The README says this speed is “fast enough to melt most networks.” It also says masscan scans in random order, so load is less likely to pile up on a distant network.

When you scan your own range, keep these points in mind.

  • The rate is the total number of packets per second. The fewer devices you scan, the more each one receives. If you scan one device, it receives all of them.
  • The scan order is always random, and you cannot change it. With IPv6, the probes tend to concentrate on one subnet. The README warns that in that case the target network is often overwhelmed and crashes.
  • Start at the default of 100 packets per second. When you raise the rate, do it in small steps, and watch the CPU on your routers and firewalls and the response of the devices you scan. The official documents give no figure for how much faster is safe.

Estimating how long a scan takes

The number of probes is the number of addresses times the number of ports. The time is roughly the number of probes divided by the rate. The table below is for a /24 (256 addresses) at the default rate. It does not include the wait after sending (--wait, 10 seconds by default) or retries (--retries).

Ports scanned Probes Time at 100 packets/s
3 (22, 80, 443) 768 About 8 seconds
1 to 1024 262,144 About 44 minutes
0 to 65535 (all) 16,777,216 About 47 hours

If you want to scan all ports, first consider whether you can narrow the ports before you raise the rate.

Exclude list: keep devices you must not scan out of the scan

An exclude list is a file of ranges to leave out of the scan. You pass it with --excludefile. To exclude a single range, you can use --exclude instead.

  • An exclusion overrides the target specification (from the manual).
  • The format is the same as for targets. Put one IP address, range, or CIDR block on each line.
  • In the source, lines that start with # are treated as comments.
  • If masscan cannot read the exclude file, it prints an error and exits. It will not start a scan without your exclusions.
  • When IPv4 ranges are added to the exclusions, masscan prints <file name>: excluding N ranges from file to standard error. Use this to confirm the exclusions took effect. Some files, such as one with only IPv6 ranges, print nothing.

Examples of devices to put on the list:

  • Old devices, control equipment, and printers whose failure would disrupt business
  • Ranges managed by other departments or contractors
  • Ranges you do not have permission to scan

On platforms other than Windows, masscan also reads /etc/masscan/masscan.conf first by default (manual, src/main.c). The author puts excludefile there so the exclusions are never forgotten. The reverse also happens: if someone left a rate or a range in that file earlier, the scan starts with settings you did not intend. Before you run a scan, check the settings with --echo.

Try it safely: take an inventory of your own range at a low rate

Try masscan on your own devices or a test network, at a low rate. The examples use 192.0.2.0/24, an address block reserved for documentation. Replace it with a range you manage.

We wrote these steps from the official README, manual, and source. We have not run masscan on a real machine.

  1. Get it and check the version. The project points you to building from source. On Debian and Ubuntu, build it like this:

    sudo apt-get --assume-yes install git make gcc
    git clone https://github.com/robertdavidgraham/masscan
    cd masscan
    make
    bin/masscan -V

    On Windows, run make with MinGW, or use the VS10 project in Visual Studio. On macOS, use make or the Xcode project. According to the README, it does not work under Cygwin.

  2. Check the name of your network card. --iflist lists the available network cards and exits.

    sudo bin/masscan --iflist
  3. Create an exclude list. Write the devices you will not scan in exclude.txt.

    # Devices not to scan (example)
    192.0.2.1
    192.0.2.200-192.0.2.210
  4. Check what masscan would send, without sending anything. --offline does not transmit packets. Combined with --packet-trace and a low rate, it shows the packets masscan would have sent (from the manual).

    sudo bin/masscan 192.0.2.0/24 -p22,80,443 --rate 100 --excludefile exclude.txt --offline --packet-trace
  5. Scan for real at a low rate. Always give the ports with -p, because masscan has no default ports. The rate here is still 100 packets per second.

    sudo bin/masscan 192.0.2.0/24 -p22,80,443 --rate 100 --excludefile exclude.txt -oL result.txt
  6. Read the result. In list format (-oL), each line has the state, protocol, port, IP address, and time (the format from the README). For example, open tcp 80 192.0.2.10 1390380064 means TCP port 80 on 192.0.2.10 is open. Compare the list with your own asset register and look for ports you did not expect.

  7. Once you have results and the devices are unaffected, raise the rate a little at a time.

We could not find any statement in the official documents about whether you must run as administrator on Windows, so that point is unconfirmed.

Common options

Option What it does
-p 22,80,8000-8100 Ports to scan. Required. U:53 means UDP
--rate 100 Packets per second. The default is 100. --max-rate is the same option
--excludefile FILE A file of ranges to exclude
--exclude RANGE Exclude one range directly on the command line
-iL FILE (--includefile) A file of ranges to scan
-oL, -oX, -oJ, -oG, -oB Result formats (list, XML, JSON, grepable, binary)
--wait SECONDS How long to wait for replies after sending finishes. The default is 10 seconds
--echo Print the current settings without running
--offline, --packet-trace Show what would be sent, without sending it
-e NAME (--adapter) The network card to use. If omitted, the first card with a default gateway

Targets must be IP addresses or ranges. Host names and Nmap’s 10.0.0-255.0-255 notation do not work.

How masscan differs from Nmap

Nmap also finds open ports. The README describes masscan as built for scanning many machines across a wide range, and Nmap as built for scanning one machine or a small range in depth.

masscan Nmap
Strength Scans ports across a wide range at once Examines a few devices in detail, down to service versions and the OS
How it sends Sends SYN with its own TCP/IP stack (SYN scan only) Also uses the OS’s own stack. Falls back to a connect scan without privileges
Default ports None. -p is required The 1,000 most common
How you name targets IP addresses and ranges only (no host names) Host names and its own range notation also work
License AGPL-3.0 Nmap Public Source License

One way to combine them: use masscan to find open ports across a wide range, then rescan only the ports it found with Nmap’s -sV. This is our suggestion, not an official procedure.

Cautions

  • Do not scan ranges you have no permission to scan. The manual says to get written permission from your boss, with a clear statement of purpose, before you scan outside your local subnet. It also warns that even a scan inside your organization can lead to disciplinary action after someone sees it in their logs. It adds that scanning from your home connection may lead your provider to cancel your account over abuse complaints.
  • Do not use it on the whole Internet or on other people’s ranges. This review does not cover how.
  • On a production business network, scan at a low rate, at a time when an outage would not matter. A high transmit rate floods your own line and router.
  • The license is AGPL-3.0. The README says masscan is distributed under version 3 of the license. Using it only for internal inventory is unlikely to cause problems. If you modify it and distribute it, or offer it as a service over a network, read the license terms.
  • You need administrator (root) privileges and a packet library. On Linux and macOS, when privileges are missing, the source prints a hint to run with sudo or as root. On Windows, you need WinPcap or Npcap. If neither is found, masscan prints a message asking you to install one.
  • With --banners, the operating system can send unwanted RST packets. Because masscan uses its own stack, the OS answers the SYN-ACK with an RST and the connection drops. The README suggests using a separate source IP address or blocking the source port with a firewall. A wrong setting can disrupt another device that uses the same IP address, so this review does not use it.
  • The official releases include no prebuilt binaries (the GitHub releases have no attached files). The latest release is 1.3.2 from January 2021, but development has continued since (the repository was updated on October 5, 2026). The version string in the source (1.3.9-integration) does not match the release version. Check the version you use with -V.

Sources

  1. Official repository (robertdavidgraham/masscan)github.com/robertdavidgraham/masscan
  2. README (build, transmit rate, comparison with Nmap)github.com/robertdavidgraham/masscan/blob/master/README.md
  3. Manual page (masscan(8) options)github.com/robertdavidgraham/masscan/blob/master/doc/masscan.8.markdown
  4. LICENSE (GNU Affero General Public License v3)github.com/robertdavidgraham/masscan/blob/master/LICENSE
  5. Source: default transmit rate (src/main.c)github.com/robertdavidgraham/masscan/blob/master/src/main.c
  6. Source: loading WinPcap or Npcap on Windows (src/stub-pcap.c)github.com/robertdavidgraham/masscan/blob/master/src/stub-pcap.c
  7. Source: permission-denied errors (src/rawsock.c)github.com/robertdavidgraham/masscan/blob/master/src/rawsock.c
  8. Source: reading the exclude file (src/main-conf.c, src/massip-parse.c)github.com/robertdavidgraham/masscan/blob/master/src/main-conf.c

Checked on 2026-10-28

Similar tools

Nmap

Impact Reaches others
nmap/nmap

The standard scanner for finding hosts on a network, the ports they have open, and the services running on them.

Purpose
Audit
Type
Command line
Difficulty
Intermediate
License
Check termsNmap Public Source License
Category
Network / Reconnaissance
Actively updatedstars14,007Last update 2026-11-16
Read the Nmap review

Suricata

Impact Reaches others
OISF/suricata

An intrusion detection and prevention engine (IDS/IPS) that matches network traffic against rules and records suspicious activity as alerts.

Purpose
Defense
Type
Self-hosted server
Difficulty
Intermediate
License
CopyleftGPL-2.0
Category
Network
Actively updatedstars6,901Last update 2026-11-15
Read the Suricata review

Wireshark

Impact Reaches others
wireshark/wireshark

A packet analyzer that records network traffic and breaks each packet down by protocol so you can read it.

Purpose
Learning
Type
Desktop app
Difficulty
Beginner
License
CopyleftGPL-2.0
Category
Network / Forensics
Actively updatedstars10,231Last update 2026-11-17
Read the Wireshark review