/python-dns-failover

Python script to automatically update DNS records for a bunch of servers participating in a Round-Robin DNS setup.

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Python DNS Failover

https://badge.fury.io/py/python-dns-failover.png https://travis-ci.org/marccerrato/python-dns-failover.png?branch=master https://pypip.in/d/python-dns-failover/badge.png

Python script to automatically update DNS records for a bunch of servers participating in a Round-Robin DNS setup.

This project is mainly based on @dotcloud's work on his project autodnsfailover.

The main difference is that python-dns-failover script is aimed to run in an external machine while autodnsfailover is to run in the participating servers themselves.

DNS Backends

A DNS backend is responsible for updating the DNS records. It must provide the following methods:

  • get_a_records(fqdn): Returns the list of ip adresses records associated with the given FQDN.
  • add_a_record(fqdn, ip): Adds a resource record of type A to the DNS list. Optionally return the new record created.
  • delete_a_record(fqdn, ip): Deletes all DNS A-type resource records targeting the given ip. Optionally return the number of deleted records.

The constructor will typically be implementation-dependent, and allow to set the credentials and/or the zone to act upon.

Available DNS Backends

  • CloudFlareDNS
    • email: E-mail address of your CloudFlare account.
    • key: API key of your CloudFlare account.
    • zone: target DNS full qualified domain name.
    • ttl: TTL of record in seconds. 1 = Automatic, otherwise, value must in between 120 and 4,294,967,295 seconds. Defaults to 1.
    • url: CloudFlare client gateway interface url. Defaults to 'https://www.cloudflare.com/api_json.html'.

TODO

  • Documentation
  • Testing