Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells, Networking

Identifying Available IPs on the Network

Submitted by on December 2, 2014 – 2:31 pm

At some point available IPs on your network may become few and hard to come by. Documentation becomes outdated and does not accurately reflect which IPs are still in use. A good starting point would be to scan a network segment and identify which IPs are not responding to ping. And then you can go from there to figure out which of those can be recycled.

Here’s a simple script that will help you with this task. In this example we’re looking for potentially-available IPs on the 192.168.101 subnet.

#!/bin/bash
is_alive_ping()
{
  ping -c 2 $1 > /dev/null
  [ $? -ne 0 ] && echo Node with IP: $1 is down
}
for i in 192.168.101.{1..254}
do
  is_alive_ping $i & disown
done | sort -t. -k4 -n

A word of caution: just because the IP did not respond to ping, doesn’t mean it is not in use. Always verify.

Print Friendly, PDF & Email

Leave a Reply