Skip to main content

Get the Cloud Provider netblocks

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 netblocks or pip install git+https://github.com/hm-distro/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 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

netblocks-0.0.11.tar.gz (8.3 kB view details)

Uploaded Source

File details

Details for the file netblocks-0.0.11.tar.gz.

File metadata

  • Download URL: netblocks-0.0.11.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.5.4.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.13

File hashes

Hashes for netblocks-0.0.11.tar.gz
Algorithm Hash digest
SHA256 dc166f261f53c87190fc62b530f8d8d09a971f99e6e8e1290f1aca611ef25214
MD5 1d7aea0a480d903e200f9acc1acf40a8
BLAKE2b-256 330df1328b6e827b76ffe94f9f521467874fc52bb535cdbbf7e1bd0f525da117

See more details on using hashes here.

Supported by

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