oxidized icon indicating copy to clipboard operation
oxidized copied to clipboard

Using oxidized to backup Cloudflare DNS records

Open lazynooblet opened this issue 1 year ago • 2 comments

Would a pull request be accepted for an extension/model that logs into Cloudflare via its API and exports a DNS zone?

Its something I have on my todo-list: to have my own copy of the DNS records, saved to git, and for me to get notified of changes via Teams.

I have oxidized setup and working well for our networking equipment and the git/notification peices are already in place.

I would expect the configuration to be

  • name: my.zone.com
  • ip: cloudflare-api-endpoint
  • user: cloudflare-zone-id
  • pass: cloudflare-api-key

I'd create an api-key that has read-only access to the zones I wanted to backup, and then watch the magic happen.

lazynooblet avatar Feb 02 '24 12:02 lazynooblet

So device itself is the zone and model would be some new model, which would also configure new input mechanism, instead of telnet/ssh. Seems reasonable to me. I do wonder if the input mechanism can be non-cloudflare specific, so that cloudflare specificity would be in the model, but input mechanism itself could potentially be used for other APIs like this. Or maybe no new input mechanism is needed at all, maybe existing HTTP works.

ytti avatar Feb 02 '24 13:02 ytti

I'm not a Ruby dev, so will want to keep it simple. I was hoping to use the current HTTP input as we can get a JSON output of DNS records with a single request.

curl example: curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${zoneid}/dns_records/export" -H "Authorization: Bearer $auth_token" -H "Content-Type: application/json" -o ${zonename}.txt

Which can either be saved as-is, or parsed into some delimited form of list of records for backup.

I'll fork and play about and return to this with an example, see how we go.

lazynooblet avatar Feb 02 '24 13:02 lazynooblet