I’ve got a pretty simple use case, but don’t know if someone has already built it out there. There are a lot of dynamic DNS services available out there, but they typically all require you to use their domain. I have a use case where I need to use my own domain. So I need to be able to update an A record for myhost.mydomain.com regularly.
I’m thinking it could potentially be as simple as having a local script (powershell on Windows, cURL on Linux) at my endpoint out on the Internet call an API gateway / Lambda function … the Lambda function parses the incoming public IP address out into a variable … and then updates a Route 53 record. Maybe not the most secure approach, but it’s not a high security use case.
Are there any projects in GitHub anywhere, or has anyone attempted this?
Public DNS infrastructure is complex spider web. There’s no guarantee your updated record will propagate in time. DNS services rely heavily on caching.
Why don’t you hide your endpoints behind a load balancer with a static ip?
I’m very familiar with how public DNS works, TTL, SOA, glue records, etc. I’ve written papers on the subject in years past. I just need to know if someone has built the glue to tie this together into a relatively simple and lightweight dynamic DNS capability. It seems like it would be easy to do with serverless AWS … so I’m wondering what it is I’m not thinking of.
Yep. No code I can show you, but I have a Lambda that does just this. It provides a simple REST endpoint that either serves up a webpage or a JSON blob depending on how it’s called.
It can update Route53 entries and/or update VPC firewall rules depending on how it’s called. Works well enough, though it’s simple enough I never bothered to package it up to something others could use.
Yeah, that sounds like exactly what I’m looking for. REST endpoint exposed by Lambda, simple functionality to parse the public IP out of the inbound HTTP headers … and then something to shove it over into an A record.
Packaging up just the subset for making a dynamic DNS for (practically) free seems like it would be a cool github probejct. But respect that you can’t necessarily share code with me … but can you maybe give me a few pointers to the Lambda functions you’re using for the major components?
So I did this but not totally serverlessly, it’s just a docker container running a boto script in an infinite loop that pulls down the public ip of the calling endpoint and updates Route53 itself. This was because doing the R53 update on my side or on the AWS side both required a script running locally, so it was simpler to just do it all locally + security benefits
Ideally I’d hand you a CloudFormation template, and detailed instructions, but this is sample code, and I’ve run out of time for the evening, so here you go, barely tested code it is.
It should work, but you’ll need to extend it if you want it to do anything clever other than change the IP of a Route53 entry.
Hey, this is spectacular - thanks so much! I’m really looking forward to playing around with this! A (mostly) free dynamic DNS capability is pretty powerful … thanks!
Exactly. The OP already suggests that its being controlled by a local script which means that a lot of the complexity mentioned elsewhere is not needed. You just need the above. I based mine on something I saw in Github several years ago but have personalised it more overtime.
Do you even need the 2nd step? You could just overwrite/update each time. I guess it would depend on you use case - if it was for systems that canmt be disconnected for more than a few minutes, IPs shifting would cause that and it would be a lot of DNS updating calls. Fortunately, my process is simply for systems that need to be able to check in every few days … so a bit easier.
Ha. I am actually working on something similar but for service discovery in a very niche space which as of today does not have native support. Good to see others working on similar things too.