Scan Time Reduction Techniques | Nmap Network Scanning (2024)

  • Nmap Network Scanning
  • Chapter6.Optimizing Nmap Performance
  • Scan Time Reduction Techniques

The ideal solution to long scan times is to reduce them. Thissection offers many high-level tips for doing so. Unlike manycirc*mstances in life, tuning your Nmap command line can make a hugedifference. Hot-rodding your Honda Accord with a coffee-can exhausttip, a three-foot-high spoiler, and a big red type R sticker won'treduce your 0–60 time much. Yet the section called “Scanning 676,352 IP Addresses in 46 Hours” describes howJack Mogren shaved days off his Nmap runtime by simply adding a few stickers(I mean options) to his Nmap command line.

Omit Non-critical Tests

The electronic equivalent to buying a Hummer when you neverleave the pavement or carry more than groceries is to launch anintense and comprehensive Nmap scan to obtain a relatively trivialamount of information. Wasting a few seconds per host rarely matterson a home network, but can make daily WAN scans infeasible for largeenterprises. The following list details ways to avoid common over-scanningmistakes, starting with the most egregious problems and followed by more subtle optimizations that even advanced users often forget.

Skip the port scan (-sn) when you only need to determine what hosts are online.

Some people determine whether a host is online using the command nmap <hostname>. While this works, it is overkill. Nmap will send four packets to determine that the host is up, then at least 1,000 to port scan the host. The problem is amplified when a whole network is scanned this way to find all online hosts, or one particular host.

Rather than waste time port scanning, specify -sn to do a ping scan when all you wish to know is what hosts are up or what their MAC addresses are.

Limit the number of ports scanned.

By default, Nmap scans the most common 1,000 ports. On a fast network of responsive machines, this may take a fraction of a second per host. But Nmap must slow down dramatically when it encounters rate limiting or firewalls that drop probe packets without responding. UDP scans can be agonizingly slow for these reasons. Yet the vast majority of open ports fall into just a few hundred port numbers. A port scan will be about 10 times as fast if you only scan 100 ports instead of the default 1,000. You can scan just the most popular 100 ports with the -F (fast scan) option, specify an arbitrary number of the most commonly open ports with --top-ports, or provide a custom list of ports to -p.

Skip advanced scan types (-sC, -sV, -O, --traceroute, and -A).

Some people regularly specify the -A Nmap option, which gives them the works. It causes Nmap to do OS detection, version detection, script scanning (NSE), and traceroute as well as the default port scan. Version detection can be extraordinarily useful, but can also bog down a large scan. So can NSE. When pressed for time, you can always skip -sC and -sV on the large scale scan and then perform them on individual ports as necessary later.

OS detection is not nearly as slow as version detection, but it can still easily take up 5–10 seconds per online host. Even without this, you can often guess the OS based on the name, open ports, and MAC address on a LAN. And in many cases you may not care about the OS. So -O is another candidate for only-as-necessary use. As a compromise, you can specify --osscan-limit --max-os-tries1 which tells Nmap not to retry OS detection attempts which fail to match, and also to skip OS detection against any online hosts that don't have at least one open TCP port and one closed TCP port. OS detection isn't as accurate against such hosts anyway.

Remember to turn off DNS resolution when it isn't necessary.

By default, Nmap performs reverse-DNS resolution against every host that is found to be online. It is done against all hosts if you skip the ping step with -Pn or specify -R. This was a major bottleneck when host DNS libraries were used to look up one IP at a time.

While Nmap now has a fast parallel reverse-DNS system to speed queries, they still can take a substantial amount of time. Disable them with the -n option when you don't need the data. For simple scans (such as ping scans) against a large number of hosts, omitting DNS can sometimes reduce scan time by 20% or more. DNS time is not a major factor in more involved scans which probe thousands of ports or utilize intensive features such as version detection. If you want the Nmap host machine to handle name resolution (using the gethostbyaddr function), specify the --system-dns option. Doing so can slow scans down dramatically.

Optimize Timing Parameters

Nmap offers dozens of options for providing hints and rules tocontrol scan activity. These range from high level timingaggressiveness levels provided by the-Toption(described in the section called “Timing Templates (-T)”) to thefiner-grained controls described inthe section called “Low-Level Timing Controls”. You can even combine thetwo. These options are particularly useful when scanning highlyfiltered networks where Nmap receives few responses to determine itsown timing estimates. Scan time can often be safely cut in half.Most of these options will have little effect against a local LANfilled with responsive hosts, as Nmap can determine optimal valuesitself in that case.

Separate and Optimize UDP Scans

Scanning UDP ports is important because many vulnerable servicesuse that protocol, but the timing characteristics and performancerequirements of UDP scans are much different than TCP scans. Ofparticular concern is ICMP error rate-limiting, which is extremelycommon and affects UDP scans far more often than TCP.

For these reasons, I don't recommend combining TCP and UDP scanswhen performance is critical, even though Nmap supports doing so withoptions such as -sSU. You often wantdifferent timing flags for each protocol, requiring separate command lines.the section called “Speeding Up UDP Scans” provides valuable tricksand real-life examples for improving UDP scan performance.

Upgrade Nmap

There have been many cases where I have investigated reports ofpoor Nmap performance only to find that the reporter used an ancientversion that was many years out of date. The newest versions of Nmaphave important algorithmic improvements, bug fixes,performance-enhancing features such as local network ARP scanning, andmore. The first response to performance problems should be to compareyour version of Nmap (run nmap -V) with the latestversion available from https://nmap.org.Upgrade if necessary. If it is still not fast enough, try the othertechniques in this chapter.

Execute Concurrent Nmap Instances

Some people try to speed up Nmap by executing many copies inparallel against one target each. For example, the Nessus scannerused to do this by default. This is usually much less efficient and slowerthan letting Nmap run against the whole network. Nmap has its ownparallelizationsystem that is customized to its needs, and Nmap isable to speed up as it learns about network reliability when it scansa large group. Further, there is substantial overhead in asking theOS to fork 65,536 separate Nmap instances just to scan a class B.Having dozens of copies of Nmap running in parallel is also a memorydrain since each instance loads its own copy of the data files such asnmap-services andnmap-os-db.

While launching single-host Nmap scans in parallel is a badidea, overall speed can usually be improved by dividing the scan intoseveral large groups and executing those concurrently. Don't gooverboard though. Five or ten Nmap processes are fine, but launching 100 Nmap processes at once is notrecommended. Launching too many concurrent Nmap processes leads toresource contention. Another sort of concurrency is to run Nmap fromdifferent hosts at once. You can have cron (or At on Windows)schedule local hosts on each of your networks to start scanning machineslocal to them at the same time, then mail the results to a central dataserver. Scanning your Australian network from the U.S. will be slowerthan scanning it from a local machine on that network. The difference will be evengreater if the U.S. machine must traverse extra firewalls to reach thedistant network.

Scan From a Favorable Network Location

Restrictive firewalls can turn a five-second scan into a multi-hourchore. Thelatencyand packet lossassociated with some Internetroutes doesn't help either. If you can run Nmap from host(s) local tothe target network, do so. Of course if the goal is to view thenetwork as an external attacker would, or to test the firewall,external scanning is required. On the other hand, scanning andsecuring the internal network provides defense in depth which iscritical against internal threats and those wily attackers who circumventthe firewall (see Chapter10, Detecting and Subverting Firewalls and Intrusion Detection Systems).

When doing reverse DNS resolution, especially if you have a heavily burdenedlocal nameserver, it can help to use a less busy nameserver or directly querythe authoritative nameservers. This gain is usually slight and only worth doing for repeated or enormous scans. Of course, there are sometimes non-performance reasons for choosing nameservers.

Increase Available Bandwidth and CPU Time

You can occasionally improve Nmap scan times by increasing youravailable bandwidth or CPU power. This may be done either by installinga new data line or CPU, or by halting concurrently running applicationswhich compete for these resources. For example, Nmap will run slower if you concurrently saturate your DSL line by downloading a pirate torrent of The MatrixReloaded.

It is far more common that Nmap is constrained by its owncongestion control algorithmsthan being CPU-bound or limited by theavailable local bandwidth. These controls help prevent networkflooding and increase accuracy. Increasing CPU power and localbandwidth won't help this sort of self-limiting by Nmap—timingoptions must be adjusted instead. You can test whether Nmap is CPUconstrained by monitoring your CPU load with an application such astop on Unix or the TaskManager on Windows. If your CPU spends most of its timeidle, then upgrading won't help much. To test Nmap's bandwidth usage,run it in verbose mode (-v). Nmap will then reportthe number of bytes sent and received and its execution time, as shownin Example6.1.

Example6.1.Bandwidth usage over local 100Mbps ethernet network

# nmap -v -n -p- sec.titan.netStarting Nmap ( https://nmap.org )[10 lines cut]Nmap scan report for 192.168.0.8Not shown: 65534 closed portsPORT STATE SERVICE22/tcp open sshMAC Address: 00:1A:6B:C1:33:37 (USI)Nmap done: 1 IP address (1 host up) scanned in 2.20 seconds Raw packets sent: 65536 (2.884MB) | Rcvd: 65536 (2.621MB)

Multiply the byte values by eight and divide by the execution timeto get the average bandwidth usage in bits per second. InExample6.1,Nmap received 2,621,000 bytes(Nmap considers 1,000,000 bytes to be a MB) in 2.20 seconds. Soreceive traffic was about 9.5Mbps (send rate was 10.5Mbps). Therefore the 100Mbps ethernet linkisn't likely constraining Nmap, and upgrading to gigabit ethernet won't helpmuch.

Some consumer broadband devices and other equipment struggles tohandle the rate of packets sent by Nmap, even though thesmall packet size (usually Nmap sends empty headers) keeps bandwidthlow. In Example6.1, “Bandwidth usage over local 100Mbps ethernet network”, Nmap sentabout 30,000 packets per second and received a similar number. Suchhigh packet rates can cause problem with low-quality devices. In thiscase, we see that both send and receive packet counts were 65,536,which is the number of scanned ports (65,535) plus one for the initialARP ping probe. Therefore Nmap did not encounter any packet dropsrequiring retransmission. This suggests again that the networkingequipment was not a limiting factor—Nmap was probably CPUbound.

Scan Time Reduction Techniques | Nmap Network Scanning (2024)
Top Articles
What Is API Latency? | Postman Blog
💰 My 2024 Vietnam Trip Cost: A Budget Breakdown
Nullreferenceexception 7 Days To Die
Spectrum Gdvr-2007
Victor Spizzirri Linkedin
Cintas Pay Bill
Paris 2024: Kellie Harrington has 'no more mountains' as double Olympic champion retires
9192464227
Z-Track Injection | Definition and Patient Education
Miss Carramello
Parks in Wien gesperrt
Items/Tm/Hm cheats for Pokemon FireRed on GBA
Leeks — A Dirty Little Secret (Ingredient)
Missed Connections Dayton Ohio
Highland Park, Los Angeles, Neighborhood Guide
Shasta County Most Wanted 2022
Mission Impossible 7 Showtimes Near Marcus Parkwood Cinema
R Personalfinance
Menards Eau Claire Weekly Ad
4Oxfun
R/Airforcerecruits
13301 South Orange Blossom Trail
Xpanas Indo
Ardie From Something Was Wrong Podcast
Expression&nbsp;Home&nbsp;XP-452 | Grand public | Imprimantes jet d'encre | Imprimantes | Produits | Epson France
Remnants of Filth: Yuwu (Novel) Vol. 4
Marlene2295
1475 Akron Way Forney Tx 75126
Wake County Court Records | NorthCarolinaCourtRecords.us
Rocksteady Steakhouse Menu
Glossytightsglamour
How to Watch the X Trilogy Starring Mia Goth in Chronological Order
Facebook Marketplace Marrero La
拿到绿卡后一亩三分地
Felix Mallard Lpsg
Tsbarbiespanishxxl
Weather Underground Corvallis
Letter of Credit: What It Is, Examples, and How One Is Used
Wilson Tattoo Shops
The Listings Project New York
Alpha Labs Male Enhancement – Complete Reviews And Guide
Arnesons Webcam
Grizzly Expiration Date Chart 2023
Flappy Bird Cool Math Games
Reilly Auto Parts Store Hours
Backpage New York | massage in New York, New York
552 Bus Schedule To Atlantic City
Joy Taylor Nip Slip
Marine Forecast Sandy Hook To Manasquan Inlet
Slug Menace Rs3
French Linen krijtverf van Annie Sloan
Affidea ExpressCare - Affidea Ireland
Latest Posts
Article information

Author: Rob Wisoky

Last Updated:

Views: 5560

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Rob Wisoky

Birthday: 1994-09-30

Address: 5789 Michel Vista, West Domenic, OR 80464-9452

Phone: +97313824072371

Job: Education Orchestrator

Hobby: Lockpicking, Crocheting, Baton twirling, Video gaming, Jogging, Whittling, Model building

Introduction: My name is Rob Wisoky, I am a smiling, helpful, encouraging, zealous, energetic, faithful, fantastic person who loves writing and wants to share my knowledge and understanding with you.