vik-y
8/28/2016 - 8:21 AM

Script to get all unused ips in a subnet

Script to get all unused ips in a subnet

import os, sys

# Fping must be installed in the system 
os.system('fping -a -g %s/24 > alive.txt' % (sys.argv[1]))

f = open('alive.txt', 'r')
raw = f.readlines()

ips = [int(x.split('.')[-1].strip()) for x in raw]
ips.sort()

# From the sorted list figure out the unused ips. 
print ips