Are there any AWS serverless dynamic DNS projects out there?

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?

What you are suggesting is ugly in my opinion.

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?

Because my edge endpoints aren’t in AWS?

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.

has anyone attempted this?

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?

Assuming someone doesn’t reply with such a ready made solution, I’ll gather up the bits of the solution to give you a starting point later tonight.

Thanks!

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

Here’s an example Lambda.

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!

Yeah I’ve built something for exactly this use case.

https://github.com/Krakaw/dyn-ip

I did something similar, without any component in aws (besides route53) in it though.

I created an iam user, scoped down it’s permissions to the minimum.

I have a script on my server, that:

  • checks it’s current public ip (https://myip.wtf/text)
  • checks if the route53 record points to it
  • if not, updates it with boto3

No need for lambda, api gateway, etc. Works for me.

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.

Google domains does this: https://jakeholmquist.medium.com/google-domains-dynamic-dns-with-google-domains-1dd0ea45c219

It’s a simple 2 liner, curl https://checkip.amazonaws.com/ and get the public IP, aws cli route53 and update the record.

Unless you want to learn API Gateway and Lambda

Oooooh, I like that! Make it a cron job and call it done, nice!

Sounds pretty lightweight.

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.

Yeah, it just felt right to check before the write. No, it’s no unskippable.

I run the script every minute and it just didn’t feel right to update route53 every minute :slight_smile:

Right, exactly. My use case will be much more on a “daily” scale, so I could just overwrite each time.

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.