This article quickly summarises how I now manage the DNS entry that points to the public IP address of my fibre connection, which is assigned a random new IP every 24 hours or so.
This came about from deciding to switch from Route53 to Cloudflare for DNS management. I’d already prepared the destination zones on Cloudflare but needed to update the mechanism I had in place that manages the DNS entry for the dynamic IP address. The mechanism was a NodeRED flow that made an API call directly to Route53. I’d need to do some research on how to do the same on Cloudflare.
Given what I now understood from working with ‘external-dns’, I figured I could save some time by somehow leveraging it’s ability to manage DNS entries in multiple third-party DNS providers as changes are made to Ingresses and Services in the cluster it is deployed to.
I did a quick check to see whether using an IP address in an ‘ExternalName’ service would work, and sure enough it worked as expected.
kubectl create service externalname dynamicip1 --external-name `curl icanhazip.com` kubectl annotate service dynamicip1 "external-dns.alpha.kubernetes.io/hostname=office1.dynamicip.golder.org
After a while, it checks out…
kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE dynamicip1 ExternalName <none> 188.8.131.52 <none> 99m
So I came up with a bit of Golang imaginatively called ‘update-dynamic-ip‘, which I now run in a container on a QNAP NAS in the office.
It should be pretty straightforward to understand how to build, configure and run it, but time is running short toda so I’ll add a README to the repo another day that will cover all that.