Bogons

raw JSON →
1.0.3 verified Fri May 01 auth: no python

Python library for generating and checking IP & ASN bogons (martian packets). Current version 1.0.3, release cadence irregular.

pip install bogons
error ModuleNotFoundError: No module named 'bogons'
cause Library not installed.
fix
Run pip install bogons
error AttributeError: module 'bogons' has no attribute 'is_bogon'
cause Importing the module directly instead of class instance.
fix
Use from bogons import BogonChecker then create checker = BogonChecker() and call checker.is_bogon()
gotcha BogonChecker downloads bogon lists on first instantiation. If offline or slow network, initialization may hang.
fix Ensure network connectivity or pre-download lists.
gotcha The library requires Python >=3.6. No support for Python 2.
fix Use Python 3.6+.

Basic usage: create a BogonChecker instance and check if an IP is a bogon.

from bogons import BogonChecker

checker = BogonChecker()
print(checker.is_bogon('192.168.1.1'))  # True
print(checker.is_bogon('8.8.8.8'))       # False