Thursday, January 5, 2012

List devices in local network (IP range)

A not so frequent task is to list all active devices in a local network (to find their IP addresses). Typically this is done by writing anew a tiny shell script to ping all IP addresses in the network range or a list.

A command that can be used for this purpose with advantages is nmap (a port scanner). Type nmap to see the list of options.

Examples:

Ping every host in a range of IPs (in this case from 192.168.1.1 to 192.168.1.200):

nmap -sP 10.1.1.1-200

Scan available ports/services in a range of IPs:

nmap 192.168.1.1-255

Option -O helps identifying the brand of each active device. It looks up which OS could be running on each IP and in addition looks up the vendor of that network interface, which could be the most useful information if you are looking for the IP of a specific device:

sudo nmap -O 192.168.1.1-255

[...]
MAC Address: 00:21:29:C6:27:24 (Cisco-Linksys)
Device type: general purpose
Running: Linux 2.4.X
OS details: Linux 2.4.18 - 2.4.37 (likely embedded)
Network Distance: 1 hop
[...]

Hope this post saves time.

No comments:

Post a Comment