Skip to main content

Get the Cloud Provider netblocks (Python3 version)

Project description


This is not an official Google product.

This is a Google App Engine app that regularly checks the DNS entries using the netblocks module. This App engine code updates the GCS bucket, when there is a change in the CIDR blocks for GCE.

The netblocks api module itself can be used outside App Engine. Install the package with pip install netblocks or pip install git+

Downstream systems can hook into the Object notification on the GCS bucket and accordingly do something with the file, with the updated CIDR ranges. The schedule of this refresh can be managed in the cron.yaml and the bucket and file where the CIDR ranges should be written to can be changed in the

Potential listeners could be Cloud Functions.

API Usage

import netblocks
cidr_blocks = set()
netblocks_api = netblocks.NetBlocks()
    cidr_blocks = netblocks_api.fetch()
    The cidr_blocks set contains strings like the below
except netblocks.NetBlockRetrievalException as err:
    #exception handling

The GAE App

  • UpdateGCSBucket

This class creates a file in the GCS bucket as specified in
The files contains entries such as the below:
Make sure to create a bucket prior to deploying the app
This bucket-name should be changed in the under GCS_BUCKET

Deploy using

gcloud app deploy app.yaml

gcloud app deploy cron.yaml




Run these steps before deploying the app
mkdir lib
pip install -t ./lib/ google-api-python-client
pip install -t ./lib/ GoogleAppEngineCloudStorageClient
pip install -t ./lib/ requests
pip install -t ./lib/ oauth2client
pip install -t ./lib/ requests-toolbelt


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.

Files for netblocks3, version 0.0.13rc2
Filename, size File type Python version Upload date Hashes
Filename, size netblocks3-0.0.13rc2-py3-none-any.whl (14.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size netblocks3-0.0.13rc2.tar.gz (9.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page