Keep Porkbun DNS Records Updated Automatically with Your Current IP
Jorge Alberto Díaz Orozco (Akiel)

Jorge Alberto Díaz Orozco (Akiel) @jadolg

About: Professional yak shaver. Containers whisperer. VPNs and freedom online.

Location:
Hamburg, Germany
Joined:
Jun 29, 2017

Keep Porkbun DNS Records Updated Automatically with Your Current IP

Publish Date: Jun 20
0 0

The problem

I love homelabbing. If the term is new to you, it's basically building your own computers/network lab at home. Usually with consumer hardware or old and loud professional servers. Curious? Go visit http://reddit.com/r/homelab/ for addictive material that will make you want one.

My homelab runs services of all kinds, Kubernetes clusters, and experiments I make to study and prepare myself for work plus several things my family and friends actually use.

I do have a problem though: Every time my home router restarts or re-negotiates internet connection, my public IP address changes. This is very common for home internet connections and there's plenty of software to keep your records updated but, as always, I wanted something special.

My requirements

  1. All the DDNS software I could find for Porkbun which is my current DNS provider is written in Python and not precisely well packaged. I need something easy to install and run that I can place anywhere with the minimum amount of dependencies needed.
  2. I had no good way to monitor what's happening. Let's say I want to know if the process is not working well or if my credentials are not working, or just simply knowing when an update happened. Basically, I need metrics.
  3. All the software I could find supports only one account and I didn't want to repeat the process for the several accounts I manage for my different labs. I need support for multiple accounts.

Getting my hands dirty

I think the first thing I liked about programming in Go is how portable the result is. I can just go ahead and focus on writing my software and I know it's probably going to work almost everywhere. I do like Python too, but, let's face it: it's just harder to distribute and to keep all the dependencies happy for applications. With Go you can just strip almost all system dependencies and package only your application.

So, I decided to go ahead and write my own Porkbun DDNS client in Go.

🛠 Try it out

The tool is open-source and available on GitHub:
👉 jadolg/porkbun-ddns

Features

  1. Multiple credentials are configurable so you can update records for multiple accounts.
  2. You are not restricted to only one record to update.
  3. It has IPv6 support.
  4. You can expose metrics from it and build monitoring and alerting based on them: Grafana Dashboard
  5. Timeouts and update intervals are configurable for flexibility.
  6. Extremely easy to deploy either just downloading the binary and starting it as a service or using Docker or snap with more options coming in the future.
  7. All settings are controlled via this simple YAML file:
update_interval_minutes: 5
timeout: 20s

credentials:
  prod:
    porkbun_api_key: changeme
    porkbun_secret_key: changeme
  dev:
    porkbun_api_key: changeme
    porkbun_secret_key: changeme

records:
  - domain: example.com
    host: www
    ipv6: true
    ipv4: true
    credentials: prod
  - domain: example.com
    host: blog
    ipv4: true
    credentials: dev

metrics:
  enabled: false
  port: 7879
Enter fullscreen mode Exit fullscreen mode

Final words

I know this sounds like I’m advertising my own tool—because I am. But I built it to solve real problems I think many of you face too. I love writing tools that are useful, and I hope this one helps you as much as it’s helped me.

Comments 0 total

    Add comment