{"id":545,"date":"2011-05-23T07:56:36","date_gmt":"2011-05-23T07:56:36","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2011\/05\/23\/python-script-display-addressable-ip-addresses\/"},"modified":"2021-07-24T18:32:13","modified_gmt":"2021-07-24T18:32:13","slug":"python-script-display-addressable-ip-addresses","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Programming\/Python\/python-script-display-addressable-ip-addresses.html","title":{"rendered":"Python Script : Display addressable IP addresses"},"content":{"rendered":"
Below is a short script designed to output the addressable IP addresses within a given subnet.<\/p>\n
Note <\/strong><\/em>: This script requires the netaddr python library.<\/p>\n <\/p>\n <\/p>\n <\/p><\/p>\n","protected":false},"excerpt":{"rendered":" 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\/pythonimport sysfrom netaddr import IPNetworkIPADDRESS = raw_input(‘Enter Subnet:’)try: for ip in IPNetwork(IPADDRESS).iter_hosts(): print ‘%s’ % ipexcept: print “Usage: “,sys.argv[0],”[SUBNET ID]\/[NETMASK]” print “Output addressable ip addresses within a given subnet.” … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"yoast_head":"\n#!\/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.\"<\/pre>\n