Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need a script that ping a group of ips and return as a result the online one , it will echo for example 10.10.10.10 is online

10.10.10.11 is online

10.10.10.15 is online

Without using any package or third party utility !

Any help ?

share|improve this question
add comment

2 Answers 2

No need for a script. nmap Install nmap can do it for you.

For example, to scan a 10.10.10.0/24 network, do

nmap -sn 10.10.10.0/24

This will report hosts being up based on responding to an ICMP Echo Request, known as 'ping'. An example output:

Starting Nmap 5.21 ( http://nmap.org ) at 2014-01-30 00:40 CET
Nmap scan report for 10.10.10.1
Host is up (0.0061s latency).
Nmap scan report for 10.10.10.2
Host is up (0.00071s latency).
Nmap scan report for android (10.10.10.112)
Host is up (0.0087s latency).
Nmap scan report for laptop (10.10.10.134)
Host is up (0.00037s latency).
Nmap scan report for 10.10.10.151
Host is up (0.00094s latency).
Nmap scan report for 10.10.10.203
Host is up (0.00060s latency).
Nmap done: 256 IP addresses (6 hosts up) scanned in 3.41 seconds
share|improve this answer
    
without need to any package or utility –  nux Jan 29 at 23:44
    
@nux If that was a requirement for you then that belongs in your question. And it's sad you didn't mention it in there earlier on as I have taken the time to provide an answer without that requirement being listed... –  gertvdijk Jan 29 at 23:46
    
OK you are right me friend am sorry for your time , and your answer is excellent please keep it don't delete it –  nux Jan 29 at 23:47
add comment
up vote 1 down vote accepted

The script below will loop in a subnet ips and return as a result just the online :

#!/bin/bash

is_alive_ping()
{
  ping -c 1 $1 > /dev/null
  [ $? -eq 0 ] && echo Node with IP: $i is Online.
}

for i in 10.1.1.{1..255} 
do
is_alive_ping $i & disown
done

Note change 10.1.1. to you subnet , a 1..255 tell the script to start from 10.1.1.1 and loop tell 10.1.1.255

Execute:

./ping_scan.sh
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.