Python Script : Display addressable IP addresses

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

Note : This script requires the netaddr python library.

import sys
from netaddr import IPNetwork

IPADDRESS = raw_input('Enter Subnet:')
    for ip in IPNetwork(IPADDRESS).iter_hosts():
    print '%s' % ip
print "Usage: ",sys.argv[0],"[SUBNET ID]/[NETMASK]"
    print "Output addressable ip addresses within a given subnet."




Tags: Python

About the Author


R Donato

Rick Donato is the Founder and Chief Editor of He currently works as an SDN/NFV Solutions Architect and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001