Dynamic DNS
Dynamic DNS (DDNS) is a method that automatically updates name server records with current information such as hostnames and IP addresses. This is particularly useful for users hosting services on a home network with a dynamic public IP address, which can change over time due to ISP policies or network restarts.
By using DDNS, users can maintain consistent access to their services over the internet via a fixed domain name, even as their IP address changes. The DDNS client software or service detects IP changes and promptly updates the DNS records to ensure reliable remote connectivity.
There are many options to choose from, some are provider specific.
Confiuration example
One easy to setup DNS updater is ddns-updater. It may be configured like so:
services.ddns-updater = {
enable = true;
environment = {
SERVER_ENABLED="no";
CONFIG_FILEPATH = "/etc/ddns-updater/config.json";
PERIOD = "5m";
};
};
Where CONFIG_FILEPATH should correspond to the location of your config.json file.
The following is an example for the provider Porkbun. Consult the documentation of your DNS provider for proper formatting and make sure to enable API access if needed.
{
"settings": [
{
"provider": "porkbun",
"domain": "example.org",
"api_key": "pk1_1234567",
"secret_api_key": "1234567890abcdefg1234567890"
},
{
"provider": "porkbun",
"domain": "subdomain.example.org",
"api_key": "pk1_1234567890abcdefg1234567890",
"secret_api_key": "sk1_1234567890abcdefg1234567890"
}
]
}
You can verify proper operation using journalctl -u ddns-updater.service. Note that previous manual DNS entries might not be overwritten using this tool and need to be deleted first.