Last active
November 23, 2022 17:16
-
-
Save fagci/27d151c35bb0010ec7826284001858fe to your computer and use it in GitHub Desktop.
Random public (global) IP v4 addresses generator
This file contains 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 IPv4Address | |
from random import randrange | |
def generate_ips(count=20): | |
while count: # negative values makes infinite generator | |
ip_address = IPv4Address(randrange(0x01000000, 0xffffffff)) | |
if ip_address.is_global and not ip_address.is_multicast: | |
count -= 1 | |
yield str(ip_address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment