Last active
June 1, 2021 18:47
-
-
Save wesinator/c18b53ad32b2eb353dfc52139c55d869 to your computer and use it in GitHub Desktop.
See https://netaddr.readthedocs.io/en/latest/tutorial_01.html#public for a faster version
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
#!/usr/bin/env python3 | |
from IPy import IP | |
def getIPtype(ip): | |
try: | |
return IP(ip).iptype() | |
except ValueError: | |
return None | |
def ipPublic(ip): | |
if getIPtype(ip) == "PUBLIC": | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment