Skip to main content

Ping to many host/node in one command

We can use "for loop" in interactive command, here is the example:
we want to ping host/node from 10.100.11.1 until 10.100.11.10:

We use "i" as a variable, values of "i" are 1 until 10. In the ping option, we use "-c 1" this means that we send ping packet only one (default in linux is continues until stopped).

here is the result:
[syam@borneo03 ~]$ for i in {1..10}; do ping 10.100.11.$i -c 1; done
PING 10.100.11.1 (10.100.11.1) 56(84) bytes of data.
64 bytes from 10.100.11.1: icmp_seq=1 ttl=64 time=1.58 ms

--- 10.100.11.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 1.587/1.587/1.587/0.000 ms
PING 10.100.11.2 (10.100.11.2) 56(84) bytes of data.
64 bytes from 10.100.11.2: icmp_seq=1 ttl=64 time=1.09 ms

--- 10.100.11.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 1.093/1.093/1.093/0.000 ms
PING 10.100.11.3 (10.100.11.3) 56(84) bytes of data.
64 bytes from 10.100.11.3: icmp_seq=1 ttl=64 time=1.69 ms

--- 10.100.11.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 1.696/1.696/1.696/0.000 ms
PING 10.100.11.4 (10.100.11.4) 56(84) bytes of data.
64 bytes from 10.100.11.4: icmp_seq=1 ttl=64 time=1.70 ms

--- 10.100.11.4 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 1.700/1.700/1.700/0.000 ms
PING 10.100.11.5 (10.100.11.5) 56(84) bytes of data.
64 bytes from 10.100.11.5: icmp_seq=1 ttl=64 time=1.68 ms

--- 10.100.11.5 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 1.686/1.686/1.686/0.000 ms
PING 10.100.11.6 (10.100.11.6) 56(84) bytes of data.
64 bytes from 10.100.11.6: icmp_seq=1 ttl=64 time=1.70 ms

--- 10.100.11.6 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 1.703/1.703/1.703/0.000 ms
PING 10.100.11.7 (10.100.11.7) 56(84) bytes of data.
64 bytes from 10.100.11.7: icmp_seq=1 ttl=64 time=1.70 ms

--- 10.100.11.7 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 1.702/1.702/1.702/0.000 ms
PING 10.100.11.8 (10.100.11.8) 56(84) bytes of data.
64 bytes from 10.100.11.8: icmp_seq=1 ttl=64 time=0.721 ms

--- 10.100.11.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.721/0.721/0.721/0.000 ms
PING 10.100.11.9 (10.100.11.9) 56(84) bytes of data.
64 bytes from 10.100.11.9: icmp_seq=1 ttl=64 time=1.67 ms

--- 10.100.11.9 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 1.671/1.671/1.671/0.000 ms
PING 10.100.11.10 (10.100.11.10) 56(84) bytes of data.
64 bytes from 10.100.11.10: icmp_seq=1 ttl=64 time=1.68 ms

--- 10.100.11.10 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 1.683/1.683/1.683/0.000 ms
[syam@borneo03 ~]$
we can combine with grep to filter the result, for example we "grep" the ping:
for i in {1..10}; do ping 10.100.11.$i -c1 | grep 64; done
 Just guess the result ;-)

Comments

Popular posts from this blog

Notes: about de novo assembly

De novo assembly [SFG standford]: http://sfg.stanford.edu/denovo.html A combined approach for de novo dna sequence assembly of very short reads (IPSJ transaction on Bioinformatics): https://www.jstage.jst.go.jp/article/ipsjtbio/4/0/4_0_21/_article to be continued...

Ping Statistic Smartfren

Gambar diatas adalah hasil tangkapan layar ping statistics ke facebook.com menggunakan jaringan smartfren. Meski indikator sinyal EVDO menunjukkan full bar , tetap saja bukan jaminan akan mendapatkan koneksi stabil, gambar tersebut adalah buktinya. Statistik ping tersebut diambil pada malam hari antara pukul 22.00 s.d. 01.00. Loss yang didapatkan cukup tinggi, yaitu sebesar 14%. Jangkauan (coverage area) jaringan smartfren yang sudah mendukung EVDO Rev.A sudah cukup luas, hanya saja terkadang koneksinya tidak stabil. Bisa jadi karena pengguna internet dalam BTS tersebut penuh, sehingga bandwidth nya pun harus sharing dengan banyak pengguna . Beberapa waktu lalu, ketika saya menginap di Guest House Kebun Raya Cibodas, saya mendapatkan sinyal EVDO smartfren. Karena (mungkin) penggunanya sedikit, koneksinya stabil dan cepat. Padahal, jaringan GSM di guest house terbebut hanya mendapatkan EDGE, tetapi smartfren malah dapat EVDO.