CloudFlare DNS Driver Documentation

CloudFlare, Inc. is a U.S. company that provides a content delivery network and distributed domain name server services.


Instantiating the driver

To instantiate the driver you need to pass email address associated with your account and API key available on the account page to the driver constructor as shown below.

from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.CLOUDFLARE)
driver = cls('<email address>', '<api key>')

API Docs

class libcloud.dns.drivers.cloudflare.CloudFlareDNSDriver(key, secret=None, secure=True, host=None, port=None, **kwargs)[source]
  • key (str) – API key or username to used (required)
  • secret (str) – Secret password to be used (required)
  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.
  • host (str) – Override hostname used for connections.
  • port (int) – Override port used for connections.


create_zone(domain, type='master', ttl=None, extra=None)

Create a new zone.

  • domain (str) – Zone domain name (e.g.
  • type (str) – Zone type (master / slave).
  • ttl (int) – TTL for new records. (optional)
  • extra (dict) – Extra attributes (driver specific). (optional)
Return type:



Delete a zone.

Note: This will delete all the records belonging to this zone.

Parameters:zone (Zone) – Zone to delete.
Return type:bool
ex_blacklist_ip(zone, ip)[source]

Blacklist the provided IP.


Disable development mode.


Disable IPv6 support for the provided zone.


Enable development mode. When Development Mode is on the cache is bypassed. Development mode remains on for 3 hours or until when it is toggled back off.


Enable IPv6 support for the provided zone.


Retrieve current threat score for a given IP. Note that scores are on a logarithmic scale, where a higher score indicates a higher threat.


Retrieve all current settings for a given zone.

ex_purge_cached_file(zone, url)[source]

Purge single file from CloudFlare’s cache.

Parameters:url (str) – URL to the file to purge from cache.

Purge CloudFlare of any cached files.

ex_set_zone_cache_level(zone, level)[source]

Set the zone caching level.

Parameters:level (str) – Caching level. Valid values are: agg (aggresive), basic.
ex_set_zone_security_level(zone, level)[source]

Set the zone Basic Security Level to I’M UNDER ATTACK! / HIGH / MEDIUM / LOW / ESSENTIALLY OFF.

Parameters:level (str) – Security level. Valid values are: help, high, med, low, eoff.
ex_unlist_ip(zone, ip)[source]

Remove provided ip from the whitelist and blacklist.

ex_whitelist_ip(zone, ip)[source]

Whitelist the provided IP.


Export Zone object to the BIND compatible format.

Parameters:zone (Zone) – Zone to export.
Returns:Zone data in BIND compatible format.
Return type:str
export_zone_to_bind_zone_file(zone, file_path)

Export Zone object to the BIND compatible format and write result to a file.

  • zone (Zone) – Zone to export.
  • file_path (str) – File path where the output will be saved.
get_record(zone_id, record_id)

Return a Record instance.

  • zone_id (str) – ID of the required zone
  • record_id (str) – ID of the required record
Return type:



Return a list of RecordType objects supported by the provider.

Returns:list of RecordType

Return a list of records for the provided zone.

Parameters:zone (Zone) – Zone to list records for.
Returns:list of Record

Return a list of zones.

Returns:list of Zone
update_zone(zone, domain, type='master', ttl=None, extra=None)

Update an existing zone.

  • zone (Zone) – Zone to update.
  • domain (str) – Zone domain name (e.g.
  • type (str) – Zone type (master / slave).
  • ttl (int) – TTL for new records. (optional)
  • extra (dict) – Extra attributes (driver specific). (optional)
Return type: