Skip to content

mumenthalers/dyn-dns-easy

Repository files navigation

dyn-dns-easy

easy dynamic dns built on AWS

Architecture

Lambda, DynamoDB, Route53

How to use

Prereq: aws profile configured for sso login. if not yet done, follow this guide.

create a .env file in the project root directory with the following content:

AWS_PROFILE=YOUR_AWS_PROFILE_NAME_CONFIGURED_IN_YOUR_AWS_CONFIG
AWS_REGION=THE_REGION_YOU_WANT_TO_DEPLOY_TO
AWS_HOSTED_ZONE_IDS=COMMA_SEPARATED_LIST_OF_THE_IDS_OF_YOUR_HOSTED_ZONE_IDS
  1. install all deps
npm ci
  1. set env and login
source set_env
aws sso login
  1. build it
npm run build
  1. deploy
npm run deploy

How to use

  1. create entry in DynamoDB in the following format:
    • make sure the used zone id was provided to the env key when deploying, otherwise add it and deploy again
    • it is up to you how long the ttl should be, depending on how often you want to call the api
    • generate a secret key and use it in the request to update the record
{
  "hostname": { "S": "my-host-name.ch" },
  "zoneId": { "S": "your-zone-for-your-domain" },
  "recordTtl": { "N": "172800" },
  "secret": { "S": "a-very-secret-key" }
}
  1. after deploying you can execute the following command to get the api endpoint.
    the command writes the outputs.json file which contains the api endpoint variable
./get-stack-outputs
  1. on the given endpoint you can now update the ip address of the record by sending a post request
    • first get your public ip (e.g. by calling the api (see apiFnUrl in outputs.json)
    • store the current timestamp (seconds since epoch) in a variable
    • then calculate the hash (sha256 hex) of ipAddress + hostname + tiemstamp + secret (joined without any special characters)
    • finally send the following json to the endpoint
{
  "ddns_hostname": "my-host-name.ch",
  "validation_hash": "the-calculated-hash",
  "timestamp": 1736598400
}

you can use the provided update-dns-record script to automate this process
just set the env variables SECRET, HOSTNAME and API_URL and run the script
you can also use the Dockerfile to create an image and run it as a container

About

easy dynamic dns built on AWS ready to be deployed to your account

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published