Ping sweep without NMAP

for i in `seq 1 255`; do ping -c 1 10.10.10.$i | tr \\n ' ' | awk '/1 received/ {print $2}'; done
Ping sweep without NMAP

By: hemanth
2009-08-22 09:34:27

4 Alternatives + Submit Alt

  • Usefull for when you don't have nmap and need to find a missing host. Pings all addresses from to, modify for your subnet. Timeout set to 1 sec for speed, if running over a slow connection you should raise that to avoid missing replies. This will clean up the junk, leaving just the IP address: for i in {1..254}; do ping -c 1 -W 1 10.1.1.$i | grep 'from' | cut -d' ' -f 4 | tr -d ':'; done Show Sample Output

    for i in {1..254}; do ping -c 1 -W 1 10.1.1.$i | grep 'from'; done
    SuperJediWombat · 2010-04-07 16:57:53 2
  • Waits for all pings to complete and returns ip with mac address

    (prefix="10.59.21" && for i in `seq 254`; do (sleep 0.5 && ping -c1 -w1 $prefix.$i &> /dev/null && arp -n | awk ' /'$prefix'.'$i' / { print $1 " " $3 } ') & done; wait)
    smoky · 2014-04-02 11:20:57 4
  • This version combines the best of the other suggestions and adds these features: 1. It scans a /16 subnet 2. It is very fast by running the ping commands in the background, running them in parallel. 3. Does not use the "-W" option as that's not available in older ping versions (I needed this for OS X 10.5)

    prefix="169.254" && for i in {0..254}; do echo $prefix.$i/8; for j in {1..254}; do sh -c "ping -m 1 -c 1 -t 1 $prefix.$i.$j | grep \"icmp\" &" ; done; done
    tempelorg · 2012-07-25 12:07:15 0
  • Not really an easier solution. But an example using && for (if last command returned 0). You can use || for (if last command returned other than 0).. Show Sample Output

    prefix="10.0.0" && for i in `seq 25`; do ping -c 1 $prefix.$i &> /dev/null && echo "Answer from: $prefix.$i" ; done
    xeor · 2010-04-07 17:17:21 1

What Others Think

Glad you're enjoying our blog. In future, however, it would be nice if you gave some attribution when you're posting our content here on commandlinefu. This one is from
Hal_Pomeranz · 664 weeks and 3 days ago
or... you can install fping. fping -g
dragonauta · 500 weeks and 3 days ago
Great scripts, but I'm looking for something similar for ASH (in BusyBox v1.15.3). Unfortunately none of the above works with ash. Anyone who can help?
zakhooi · 374 weeks and 6 days ago
In view of the Kindle gear, one can coordinate get the total of the colossal data he needs. Once click"> for more details. The entire of this procedure of segregating data is remarkably more direct which just takes a couple of couples of minutes.
anonymous00 · 81 weeks and 5 days ago
We should search for comfort in following exacting characteristics instead of getting money and being rich. Click for more details. There is no sure angle with respect to getting ravenous.
anonymous00 · 81 weeks ago
Since I am a standard individual from the Peertrainer Groups, I have decided to note down these suggestions. I often visit to read more details. These proposition must be realized.
anonymous00 · 81 weeks ago
There are different choices for the understudies to begin the sensible life in the wake of finishing impelled guidance. I often visit to read more ideas. Impelled guidance gives the chances to the understudies to begin the ace employment as appeared by their arrangement.
anonymous996 · 81 weeks ago
It is ideal if the enlightening toy that is picked plays music, whether or not that it isn't the essential reason for get together of the toy. Visit">homepage to read more ideas. A melodic toy won't simply be fun and drawing in for a young adult to play with, it would show them a ton.
Ahmed74 · 77 weeks and 2 days ago
The most phenomenal thing in the whole web recording is the presence of Waking Me Softly. Visit homepage for more ideas. Looking at this tune in this time length has filled my heart with fulfillment.
Ahmed74 · 77 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: