Skip to main content

Get the Cloud Provider netblocks (Python3 version)

Project description

Netblocks

This is not an official Google product.

This module retrieves the DNS entries recursively as per the below links

The GCE ranges
    https://cloud.google.com/compute/docs/faq#where_can_i_find_product_name_short_ip_ranges
The Google Services ranges
    https://support.google.com/a/answer/60764
The AWS ranges
    https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html

Install the package with pip install netblocks3 or pip install git+https://github.com/tomasfse/netblocks/

The fetch() method has the default parameter value of initial_dns_list=[GOOGLE_INITIAL_CLOUD_NETBLOCK_DNS, GOOGLE_INITIAL_SPF_NETBLOCK_DNS]

where

#The GCE ranges
GOOGLE_INITIAL_CLOUD_NETBLOCK_DNS = "_cloud-netblocks.googleusercontent.com"

#The Google Services ranges
GOOGLE_INITIAL_SPF_NETBLOCK_DNS= "_spf.google.com"

#The AWS ranges
AWS_IP_RANGES="https://ip-ranges.amazonaws.com/ip-ranges.json"

See here on how to use this module in Google App Engine

API Usage

import netblocks3 as netblocks
cidr_blocks = set()
api = netblocks.NetBlocks()
try:
    # returns both GOOGLE_INITIAL_CLOUD_NETBLOCK_DNS and GOOGLE_INITIAL_SPF_NETBLOCK_DNS
    cidr_blocks = api.fetch()
    
    # To get only the SPF list use the below:
    #  cidr_blocks = api.fetch([netblocks.GOOGLE_INITIAL_SPF_NETBLOCK_DNS])

    
    # To get only the GCE list use the below:
    #  cidr_blocks = api.fetch([netblocks.GOOGLE_INITIAL_CLOUD_NETBLOCK_DNS]) 
    
    # To get only the AWS list use the below:
    #  cidr_blocks = api.fetch([netblocks.AWS_IP_RANGES]) 
    
    """
    The cidr_blocks set contains strings like the below
    ip4:146.148.2.0/23
    ...
    ip6:2600:1900::/35
    """
    
except netblocks.NetBlockRetrievalException as err:
    #exception handling
    pass

Language

Dependencies

requests

License

Apache 2.0; see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netblocks3-0.0.15.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netblocks3-0.0.15-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file netblocks3-0.0.15.tar.gz.

File metadata

  • Download URL: netblocks3-0.0.15.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.1 Linux/4.15.0-91-generic

File hashes

Hashes for netblocks3-0.0.15.tar.gz
Algorithm Hash digest
SHA256 cf4e1cd2d2f60abeb251ba3d321ec1a42007e1b77dd1520b65e18702bf712b27
MD5 4a033d994a18f744f90cfc08361f451c
BLAKE2b-256 86a3a15620e905a3f1034bf7beb5bc296c4be8625ab3e697e8dfd9665bde307b

See more details on using hashes here.

File details

Details for the file netblocks3-0.0.15-py3-none-any.whl.

File metadata

  • Download URL: netblocks3-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.1 Linux/4.15.0-91-generic

File hashes

Hashes for netblocks3-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 a6861e0ada6b481bdd7cf56f4574701296a51fb0a8268e28360328c8f4dfa32f
MD5 c380dc212a717c3912d1ab18484669b5
BLAKE2b-256 daf3475e18436e9c6da0533eba9265ca8428dcbe942a2bf6de1c68e510a7a5df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page