Last active
January 28, 2019 14:58
-
-
Save kkroesch/53f2609dd53c96299df69cda03a91cb5 to your computer and use it in GitHub Desktop.
Iterate IP range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ipaddress import ip_address | |
""" Two IP addresses are known """ | |
start = ip_address('192.168.1.0') | |
end = ip_address('192.168.1.254') | |
print("From {} to {}".format(start, end)) | |
for ip in range(int(start), int(end)): | |
print(ip_address(ip)) | |
""" Network address is known """ | |
from ipaddress import ip_network | |
list(ip_network('192.0.2.0/29').hosts()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment