Python Dynamic DNS

May 20, 2022

Python based Dynamic DNS Application that works with the Cloudflare API.


I initially started this project so I could update my Cloudflare DNS without using an outside account. So I decided it couldn’t that hard.


I started by setting up my config files and the parts to read from the easily and effectively. Then I downloaded and started playing with python-cloudflare… turns out it is very difficult to use and decode what is happening within it. So I decided that I would write a miniaturized version of it for myself to use utilizing the requests API. In my opinion my code is much cleaner and more readable than that written by Cloudflare. Take a look at this example to delete a DNS record.


import sys
import CloudFlare

def main():
    zone_name = sys.argv[1]
    cf = CloudFlare.CloudFlare()
    zone_info = cf.zones.get(params={'name': zone_name})
    zone_id = zone_info['id']

    dns_name = sys.argv[2]
    dns_records = cf.zones.dns_records.get(zone_id, params={'name':dns_name + '.' + zone_name})
    for dns_record in dns_records:
        dns_record_id = dns_record['id']
        r = cf.zones.dns_records.delete(zone_id, dns_record_id)

if __name__ == '__main__':

My Code

import network.Remote # This is what it is called within this project.

def main():
    cf = Remote(token, zone_name)

if __name__ == "__main__":


I enjoyed doing this project, it allowed me to learn more about the rest API system as well as gain a stronger understanding of python requests. After doing this project and getting it to a v1.0.0 release I have decided that I should work on a Python API wrapper for the Cloudflare API becasue of just how atrocious the one by Cloudflare was written.


This project is up on GitHub here and the latest version can be downloaded here.