Wednesday, May 21, 2014

Find used ip address in a subnet

[kamal@sama ~]$ for ip in $(seq 1 254); do ping -c 1 192.168.10.$ip; done


[kamal@sama ~]$ nmap -n -sP 192.168.10.0/24  


Starting Nmap 5.51 ( http://nmap.org ) at 2014-05-21 22:26 EDT
Nmap scan report for 192.168.10.1
Host is up (0.00064s latency).
Nmap scan report for 192.168.10.13
Host is up (0.017s latency).
Nmap scan report for 192.168.10.14
Host is up (0.023s latency).
Nmap scan report for 192.168.10.24
Host is up (0.076s latency).
Nmap scan report for 192.168.10.110
Host is up (0.00011s latency).
Nmap done: 256 IP addresses (5 hosts up) scanned in 5.30 seconds
[kamal@sama ~]$


[kamal@sama ~]$ for ip in $(seq 1 254); do ping -c 1 192.168.10.$ip; done
PING 192.168.10.1 (192.168.10.1) 56(84) bytes of data.
64 bytes from 192.168.10.1: icmp_seq=1 ttl=64 time=0.405 ms

--- 192.168.10.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.405/0.405/0.405/0.000 ms
PING 192.168.10.2 (192.168.10.2) 56(84) bytes of data.
From 192.168.10.110 icmp_seq=1 Destination Host Unreachable

--- 192.168.10.2 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 3000ms

PING 192.168.10.3 (192.168.10.3) 56(84) bytes of data.
^Z
[2]+  Stopped                 ping -c 1 192.168.10.$ip
[kamal@sama ~]$


[kamal@sama ~]$ for ip in $(seq 1 254); do ping -c 1 192.168.10.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.10.$ip UP" || : ; done
192.168.10.1 UP
192.168.10.13 UP
192.168.10.14 UP
192.168.10.17 UP
192.168.10.24 UP


on Windows, at dos prompt type,

for /L %I in (1,1,254) DO ping -w 30 -n1 192.168.1.%I | find "Reply"

No comments:

Post a Comment