Python Script : Display addressable IP addresses
Monday, 23 May 2011 07:56

Below is a short script designed to output the addressable IP addresses within a given subnet.

Note : This script requires the netaddr python library.

#!/usr/bin/python
import sys
from netaddr import IPNetwork
IPADDRESS = raw_input('Enter Subnet:')
try:
        for ip in IPNetwork(IPADDRESS).iter_hosts():
                print '%s' % ip
except:
        print "Usage: ",sys.argv[0],"[SUBNET ID]/[NETMASK]"
        print "Output addressable ip addresses within a given subnet."



 
We have 25 guests online