Octodns - Because you can manage DNS records easier

Octodns - Because you can manage DNS records easier

A few months earlier, Cloudflare updated their DNS management console, and to be honest, I think they made their console worse: the loading time is longer than before, and it’s harder to add new records. At about the same time, I was thinking how to manage DNS records, because in our club, multiple people have management premission to the same domain, and I can’t find a overview page or something like that to tell me who did what changes to the domain. I need a tool to help me to manage those records.

After a little bit of searching, I found a tool called Octodns, it’s a DNS management tool used and developed by GitHub. OK, if GitHub developed and used it, it can’t be bad, right?

As it turns out, Octodns is very easy and convenient to use, and I use it to manage DNS records for all my domains now.

To start using Octodns, you need to install it first. Create a folder, then use virtualenv to install octodns

1
2
3
4
$ mkdir dns && cd ./dns
$ virtualenv .env
$ source .env/bin/activate
$ pip install octodns

Now, you need to add config file for octodns, create a folder called config and create file config.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---
manager:
max_workers: 2

providers:
config:
class: octodns.provider.yaml.YamlProvider
directory: ./resources
default_ttl: 3600
dyn:
class: octodns.provider.dyn.DynProvider
customer: 1234
username: 'username'
password: env/DYN_PASSWORD
route53:
class: octodns.provider.route53.Route53Provider
access_key_id: env/AWS_ACCESS_KEY_ID
secret_access_key: env/AWS_SECRET_ACCESS_KEY

zones:
example.com.:
sources:
- config
targets:
- dyn
- route53

The YAML above means

  • Octodns will communicate with DynDNS and AWS Route53 to manage your DNS records.
  • Octodns will look for DYN_PASSWORD, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in you environment variable, so you don’t need to write your token into your YAML.
  • Octodns will manage example.com, it will be looking for example.com.yaml in resources folder.

Octodns support multiple DNS provider, like Akamai, Cloudflare, DNSimple…and lots more, you can check if your provider is supported or not at octodns/provider.

Now, if you want to add record for example.com, you need to create folder resources in your dns folder, not configs folder, and create file example.com.yaml, the config file should look like this:

1
2
3
4
5
6
7
---
'':
ttl: 60
type: A
values:
- 1.2.3.4
- 1.2.3.5

This means the top domain (example.com) will have a A record, and the value of that A record will be 1.2.3.4 and 1.2.3.5.

If you’re done with your records, run octodns-sync --config-file ./config/config.yaml to do a dry-run for your configuration, you can review what change you’re going to perform to the domain. And if everything looks good, add --doit parameter to the command above, then octodns will sync the records with DNS provider.

“Wait, what if I’m already using DNS provider to manage my DNS records? Do I need to write YAML for existing records first?”

No, octodns provides a tool called octodns-dump to create a DNS records configuration YAML for you, so you don’t need to manually create records yourself, just dump it and you’re done. The command is octodns-dump --config-file=config/config.yaml --output-dir=resources/ example.com. route53. The command will dump records for example.com from Route53, and create a file called example.com.yaml in folder resources.

The main reason for using DNS manager like this is, imagine you are in a team around 10 people, and everyone have the permission to modify DNS records, if there are no tools to manage and review changes for DNS records, it will be hard to trace changes.

Give octodns a shot, I think you will love it.