Network discovery is a process to find other computers and devices on some network and to get obtainable information about them. The discovery procedure is based on sending out request messages over and analyzing responses from remote devices. ICMP (Internet Control Message Protocol) is most frequently method detect remote device. Below is presented simple Linux shell script to find pingable devices withing appropriate IPv4 range.
#! /bin/bash start_message() { echo “Correct argument required, example: 192.168.1.0-127” exit 1 } echo “Pinging IP range” |
The script was tested on CentOS and Ubuntu. The script can be download from icmpscan.sh.zip.
The result of scanning IP range from 149.56.221.1 to 149.56.221.110 (The list of pingable IP addresses):
# ./icmpscan.sh 149.56.221.1-110 Pinging IP range Ping this IP range: 149.56.221.1-110 149.56.221.17 (64 bytes from 149.56.221.17: icmp_seq=1 ttl=49 time=51.6 ms) 149.56.221.18 (64 bytes from 149.56.221.18: icmp_seq=1 ttl=49 time=53.3 ms) 149.56.221.19 (64 bytes from 149.56.221.19: icmp_seq=1 ttl=48 time=53.1 ms) 149.56.221.20 (64 bytes from 149.56.221.20: icmp_seq=1 ttl=49 time=52.9 ms) 149.56.221.21 (64 bytes from 149.56.221.21: icmp_seq=1 ttl=49 time=53.7 ms) 149.56.221.22 (64 bytes from 149.56.221.22: icmp_seq=1 ttl=48 time=54.2 ms) 149.56.221.23 (64 bytes from 149.56.221.23: icmp_seq=1 ttl=48 time=53.4 ms) 149.56.221.24 (64 bytes from 149.56.221.24: icmp_seq=1 ttl=49 time=53.1 ms) 149.56.221.25 (64 bytes from 149.56.221.25: icmp_seq=1 ttl=49 time=50.6 ms) 149.56.221.26 (64 bytes from 149.56.221.26: icmp_seq=1 ttl=48 time=52.7 ms) 149.56.221.27 (64 bytes from 149.56.221.27: icmp_seq=1 ttl=48 time=53.0 ms) 149.56.221.28 (64 bytes from 149.56.221.28: icmp_seq=1 ttl=48 time=53.0 ms) 149.56.221.29 (64 bytes from 149.56.221.29: icmp_seq=1 ttl=49 time=54.2 ms) 149.56.221.30 (64 bytes from 149.56.221.30: icmp_seq=1 ttl=49 time=53.8 ms) 149.56.221.38 (64 bytes from 149.56.221.38: icmp_seq=1 ttl=50 time=52.4 ms) 149.56.221.56 (64 bytes from 149.56.221.56: icmp_seq=1 ttl=50 time=67.8 ms) 149.56.221.57 (64 bytes from 149.56.221.57: icmp_seq=1 ttl=50 time=54.0 ms) 149.56.221.65 (64 bytes from 149.56.221.65: icmp_seq=1 ttl=50 time=55.7 ms) 149.56.221.66 (64 bytes from 149.56.221.66: icmp_seq=1 ttl=49 time=59.2 ms) 149.56.221.67 (64 bytes from 149.56.221.67: icmp_seq=1 ttl=50 time=54.0 ms) 149.56.221.68 (64 bytes from 149.56.221.68: icmp_seq=1 ttl=49 time=56.3 ms) 149.56.221.69 (64 bytes from 149.56.221.69: icmp_seq=1 ttl=50 time=59.7 ms) 149.56.221.70 (64 bytes from 149.56.221.70: icmp_seq=1 ttl=49 time=63.9 ms) 149.56.221.75 (64 bytes from 149.56.221.75: icmp_seq=1 ttl=48 time=53.2 ms) 149.56.221.77 (64 bytes from 149.56.221.77: icmp_seq=1 ttl=49 time=52.6 ms) 149.56.221.78 (64 bytes from 149.56.221.78: icmp_seq=1 ttl=49 time=52.7 ms) 149.56.221.80 (64 bytes from 149.56.221.80: icmp_seq=1 ttl=49 time=52.2 ms) 149.56.221.81 (64 bytes from 149.56.221.81: icmp_seq=1 ttl=49 time=52.7 ms) 149.56.221.82 (64 bytes from 149.56.221.82: icmp_seq=1 ttl=48 time=50.2 ms) 149.56.221.83 (64 bytes from 149.56.221.83: icmp_seq=1 ttl=48 time=52.6 ms) 149.56.221.84 (64 bytes from 149.56.221.84: icmp_seq=1 ttl=49 time=54.7 ms) 149.56.221.85 (64 bytes from 149.56.221.85: icmp_seq=1 ttl=49 time=56.8 ms) 149.56.221.86 (64 bytes from 149.56.221.86: icmp_seq=1 ttl=48 time=57.6 ms) 149.56.221.87 (64 bytes from 149.56.221.87: icmp_seq=1 ttl=49 time=56.4 ms) 149.56.221.88 (64 bytes from 149.56.221.88: icmp_seq=1 ttl=48 time=50.0 ms) 149.56.221.89 (64 bytes from 149.56.221.89: icmp_seq=1 ttl=48 time=50.5 ms) 149.56.221.90 (64 bytes from 149.56.221.90: icmp_seq=1 ttl=48 time=56.8 ms) 149.56.221.91 (64 bytes from 149.56.221.91: icmp_seq=1 ttl=48 time=54.7 ms) 149.56.221.92 (64 bytes from 149.56.221.92: icmp_seq=1 ttl=49 time=53.1 ms) 149.56.221.93 (64 bytes from 149.56.221.93: icmp_seq=1 ttl=48 time=53.6 ms) 149.56.221.94 (64 bytes from 149.56.221.94: icmp_seq=1 ttl=49 time=53.4 ms) 149.56.221.95 (64 bytes from 149.56.221.95: icmp_seq=1 ttl=49 time=52.4 ms) |
For some ping version icmp_seq must be replaced with icmp_req in “grep icmp_seq=1” statement.
# ./icmpscan.sh 192.168.2.1-254 Pinging IP range Ping this IP range: 192.168.2.1-254 192.168.2.1 (64 bytes from 192.168.2.1: icmp_req=1 ttl=64 time=3.96 ms) 192.168.2.11 (64 bytes from 192.168.2.11: icmp_req=1 ttl=128 time=9.78 ms) 192.168.2.14 (64 bytes from 192.168.2.14: icmp_req=1 ttl=128 time=0.499 ms) 192.168.2.20 (64 bytes from 192.168.2.20: icmp_req=1 ttl=255 time=9.49 ms) 192.168.2.113 (64 bytes from 192.168.2.113: icmp_req=1 ttl=64 time=14.3 ms) 192.168.2.169 (64 bytes from 192.168.2.169: icmp_req=1 ttl=64 time=0.037 ms) 192.168.2.215 (64 bytes from 192.168.2.215: icmp_req=1 ttl=64 time=26.7 ms) 192.168.2.247 (64 bytes from 192.168.2.247: icmp_req=1 ttl=64 time=17.8 ms) |