Identifying Available IPs on the Network
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.