Using OctoDNS To Update DNS

From Sympl Wiki
Jump to navigation Jump to search
This article is Community Documentation and any changes may not be compatible with future updates of Sympl, and is therefore not officially supported.
The Sympl Forum may have more information.


The Mythic Beasts DNS API can be used in conjunction with OctoDNS to automatically update DNS entries for domains running on Sympl. This guide details the steps required to configure this.

This guide assumes that the appropriate domains are using Mythic Beasts to provide Primary DNS service, and the domain has an appropriate API password configured.

Install OctoDNS

sudo apt install python3-venv  && \
mkdir -p /home/sympl/dns && \
python3 -m venv /home/sympl/dns/ && \
/home/sympl/dns/bin/pip3 install pip octodns

Create config file

Sample configuration file (should be saved as /home/sympl/dns.yaml)


   class: octodns.source.tinydns.TinyDnsFileSource
   directory: /srv/
   default_ttl: 3600
   class: octodns.source.tinydns.TinyDnsFileSource
   directory: /srv/
   default_ttl: 3600
   class: octodns.source.tinydns.TinyDnsFileSource
   directory: /srv/
   default_ttl: 3600

   class: octodns.provider.mythicbeasts.MythicBeastsProvider
   passwords: 'mythicdnsapipasswordgoeshere'


     - mythicbeasts

Create script to cleanup published changes to remove DNS server entries

Add the following cleanup script /home/sympl/


import requests
from pprint import pprint

from yaml import load, dump
   from yaml import load, CLoader as Loader, CDumper as Dumper
except ImportError:
   from yaml import Loader, Dumper

def doRequest(values):
   response =, data = values)
   responseContents = response.text
   return responseContents

with open('/home/sympl/dns.yaml', 'r') as yamlfile:
   yamldoc = load(yamlfile)


url = ''

for domain in yamldoc['providers']['mythicbeasts']['passwords'].keys():

   yourDomain = domain.strip("'").rstrip(".")
   yourDomainAPIPass = yamldoc['providers']['mythicbeasts']['passwords'][domain].strip("'")

   print("Cleaning up '" + yourDomain + "'")

   values = {
       'domain'   : yourDomain,
       'password' : yourDomainAPIPass,
       'command'  : 'LIST'


   toDelete = False

   for line in responseContents.splitlines():
       elements = line.split()
       if elements[2]=="NS" and "" in elements[3]:
           values['command'].append("DELETE " + line)

   if toDelete:
       print("Nothing to delete")

Update Bytemark upload file

Add the following to /root/BytemarkDNS/upload immediately before the exit 0 line at the end.

# BEGIN Run OctoDNS and clean up
. /home/sympl/dns/bin/activate
octodns-sync --config-file=/home/sympl/dns.yaml --doit --force
# END Run OctoDNS and clean up

Now, whenever sympl-dns-generate is run, it will upload changes using the Mythic Beasts API. When creating new domains, update the configuration file and then manually run sympl-dns-generate.