Dynamic DNS (DDNS) is a service that keeps the DNS updated with the correct IP address, even if that IP address is being updated. It is particularly interesting for places where the IP address is dynamic and also needs to be tracked with a DNS record (for remote connection for instance). This situation is particularly common as some ISPs do not commit to static IP addresses.
Scaleway offers a DNS service with an API available. It gives the possibility to host DNS zones & records and can be configured manually from the web console or through the API. The developers documentation for the API is available here. Both nameservers (ns0.dom.scw.cloud
and ns1.dom.scw.cloud
) are hosted in France.
This article explains how to register dynamic DNS records with Scaleway DNS using scaleway-ddns
, a software specially designed for this purpose. It’s available on Linux, macOS and Windows.
The first step is to download the latest version on GitHub.
$ curl -sLO https://github.com/aerialls/scaleway-ddns/releases/download/v0.2.0/scaleway-ddns_0.2.0_linux_amd64.tar.gz
$ tar xf scaleway-ddns_0.2.0_linux_amd64.tar.gz
The software is designed to run in the background to detect new IP addresses at regular intervals and automatically perform DNS changes if necessary.
Move the downloaded file to the /usr/local/bin
directory and make sure the binary can be executed.
$ mv scaleway-ddns_0.2.0_linux_amd64/scaleway-ddns /usr/local/bin
$ chmod a+x /usr/local/bin/scaleway-ddns
In order to work, the software needs a YAML config file which contains the credentials for the Scaleway API, the domain information and also some optional parameters. Create an empty scaleway-ddns.yml
file. Credentials for the Scaleway API should be under the scaleway
key as shown in the following example.
scaleway:
project_id: b84d38dd-48b2-acde-0af89ff0f24e
access_key: SCW7XVT60TF2ECM2EK0A
secret_key: 418c21eb-ec4c-9df0-e4b5029d2d55
The project_id
can be found under the Credentials page of the Project dashboard section on the Scaleway console. Generate a new token to obtain the access_key
and the secret_key
.
The next step is to make sure that the domain is registered on Scaleway DNS. The web console or the public API can be used for that. For now, it’s only possible to register top domain (for instance aerialls.eu
and not ddns.aerialls.eu
). Follow the workflow to add the domain. In the end, it should be visible on the web console.
DNS domain information can now be added in the configuration file.
domain:
name: madalynn.net
record: ddns
ttl: 60
The previous configuration will generate a DNS record ddns.madalynn.net
with a TTL of 60 seconds. IPv4 and IPv6 are both supported. By default, IPv6 is disabled and need to be enabled manually.
For each entry, it’s possible to select the HTTP endpoint that will provide the public IP address.
ipv4:
enabled: true
url: https://api-ipv4.ip.sb/ip
ipv6:
enabled: true
url: https://api-ipv6.ip.sb/ip
It’s also possible to specify the interval between two checks with the interval
key (in seconds). The default value is set at 60 seconds. The following configuration will check every 5 minutes if the IP has changed. Note that it’s not possible to go lower than 60 seconds.
interval: 300
Notification
It’s also possible to send a Telegram notification when a change has been detected.
telegram:
enabled: true
token: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
chat_id: 74423
template: DNS record *{{ .RecordName }}.{{ .Domain }}* has been updated
The message (in Markdown) can be configured with the template
parameter. Multiple variables are available to fully personalize the message. The full list can be found in the README file in the GitHub repository.
Systemd
A systemd service can be used to automatically launch scaleway-ddns
at startup. Create a service file at /etc/systemd/system/scaleway-ddns.service
with the following content.
[Unit]
Description=Dynamic DNS service based on Scaleway DNS.
Wants=network-online.target
After=network-online.target
[Service]
User=scaleway-ddns
Group=scaleway-ddns
Type=simple
ExecStart=/usr/local/bin/scaleway-ddns --config /etc/scaleway-ddns/scaleway-ddns.yml
[Install]
WantedBy=multi-user.target
$ sudo systemctl start scaleway-ddns
$ sudo systemctl enable scaleway-ddns
The previous example will work only if the user and group scaleway-ddns
exists and the config file is located inside the /etc/scaleway-ddns
directory.
Full configuration
scaleway:
project_id: b84d38dd-48b2-acde-0af89ff0f24e
access_key: SCW7XVT60TF2ECM2EK0A
secret_key: 418c21eb-ec4c-9df0-e4b5029d2d55
domain:
name: madalynn.net
record: ddns
ttl: 60
interval: 300
ipv4:
enabled: true
url: https://api-ipv4.ip.sb/ip
ipv6:
enabled: true
url: https://api-ipv6.ip.sb/ip
telegram:
enabled: true
token: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
chat_id: 74423
template: DNS record *{{ .RecordName }}.{{ .Domain }}* has been updated
The full configuration is available on GitHub in the aerialls/scaleway-ddns repository.