AWS Route 53 Dynamic DNS

Crates.io Crates.io Build Status dependency status snapcraft.io

Introduction

This app provides a way to keep a consistant url for a network where the external ip address may change from time to time, by adding a record to a domain where the primary DNS is hosted by the Amazon Route 53 service.

There are many reasons why you would want this, the most common is to provide a URL to a service hosted on a domestic network where the ISP is not providing a static ip address, e.g. webserver, vpn to home, etc.. There are other DDNS services out there that may give you a free option, I just want to use my own domain.

This is not is a publicly facing DDNS API, for that I would recomend another repository with a similar name: aws-ddns. This is an application that provides DDNS using the R53 API, it is intended that you run this on one a computer within your network at a frequency that you are happy with.

Pre-Requisites

How it works

The application works gets it's external network address over https from some of the many services that are available online. The application has a number of these sites set up as default, but you can choose your own by providing a comma separated list of sites using the -i parameter. Many of these service have limits to the frequency that you can call them, so r532-ddns limits each run to check a random two services out of the services available. The value returned for the ip address is compared to the value that is stored in the Amazon Route 53 DNS settings, and if they differ, the DNS recordmis updated in Route 53.

Options

``` sh Set an Amazon Route 53 DNS record for the server/network

Usage: r53-ddns [OPTIONS]

Options: -s, --subdomain The subdomain to save (required) -d, --domain The domain to save the record in (required) -r, --region The aws region, [default: us-east-1] -i, --ipaddress-svc The ip address services to use, e.g. ident.me,ifconfig.me/ip -n, --nat The record is a nat router and so a *.. CNAME record will be set -v, --verbose Verbose logging -c, --check Consecutive check gap in seconds for continuous checking [default: 0] -V, --version Print version information -h, --help Print help ```

Installation

Usage

r53-ddns can be used adhoc if you wish but you probably want to set this up to run continuously in case your external ip address changes. There are two ways that you can do this, using a job scheduler such as cron or as a service.

Setup with cron

The following example is an entry into a cron file that will set up the subdomain net.example.com, performing the external ip and dns check every 5 minutes, assuming that the application has been installed via snap:

sh */5 * * * * /snap/bin/r53-ddns -s=net -d=example.com

At the top of the cron file, you may also want to declare the AWS environment variables that provide the credentials:

sh AWS_ACCESS_KEY = ... AWS_SECRET_ACCESS_KEY = ...

Some of the default services used to return the external ip address of your network will stop giving you a response if called too frequently, it is recomended that you don't call them more often than once every 5 minutes without increasing the number of configured services (via the -i parameter), hence the */5 in the cron example above.

Setup as a service using systemd

``` [Unit] Description=R53 DDNS Service After=network.target StartLimitIntervalSec=0

[Service] Type=simple Restart=always RestartSec=1 User=root ExecStart=/snap/bin/r53-ddns -s=net -d=example.com -c=300

[Install] WantedBy=multi-user.target ```

sh sudo systemctl start r53-ddns

Contribute

Feel free to contribute I would be happy to take a look at any PRs raised.

Get it from the Snap Store