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."
Latest posts by Rick Donato (see all)
- How to Configure a BIND Server on Ubuntu - March 15, 2018
- What is a BGP Confederation? - March 6, 2018
- Cisco – What is BGP ORF (Outbound Route Filtering)? - March 5, 2018
Want to become a programming expert?
Here is our hand-picked selection of the best courses you can find online:
Python Zero to Hero course
Python Pro Bootcamp
Bash Scripting and Shell Programming course
Automate with Shell Scripting course
The Complete Web Development Bootcamp course
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial