Having a dynamic DNS name is useful for many reasons, but often involves complex setup especially if you use a not-so-easy provider.
A package exists for OpenWRT which can automate many of these service updates.
Installation
- Go to LuCI ⇒ System ⇒ Software
- Update Lists
- Search for
ddns - Install
luci-app-ddnsandddns-scripts - Reboot the router
AWS Route53 configuration
To use this with AWS Route53 DNS, you’ll additionally need to install the ddns-scripts-route53 package. first (in the same manner as above).
- Go to LuCI ⇒ Services ⇒ Dynamic DNS
- Click “Add new services…”
- Give the service a recognizable name
- Select the appropriate IP version scheme (v4 or v6)
- Select
route53-v1in the “DDNS Service provider” list - Click “Create Service”
Now, go to the AWS Route53 console and find the Hosted Zone ID of the hosted zone with the relevant DNS A record in it. This typically begins with a Z.
In the AWS IAM console, create and configure an IAM user which has the following permission (don’t forget to update the hosted zone ID):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1403515694000",
"Effect": "Allow",
"Action": [
"route53:ChangeResourceRecordSets",
"route53:GetHostedZone",
"route53:ListResourceRecordSets"
],
"Resource": [
"arn:aws:route53:::hostedzone/<<YOUR HOSTED ZONE ID HERE>>"
]
}
]
}Permissions scoping
It may be possible to further narrow the scope of this permission — I haven’t really tried to mess with it once I got it to work as shown above.
Create an API key for the user, and note both the key ID and secret key.
Back in OpenWRT’s DDNS Service Creation window:
- In the Basic Settings tab:
- Ensure “Enabled” is checked
- Set “Lookup hostname” ⇒ the hostname you want to map DNS for (for example,
vpn.example.com) - Confirm “IP address version” is correct
- Confirm “DDNS Service Provider” is
rotue53-v1 - Set
Domainto the Hosted Zone ID from Route53 - Set
Usernameto the key ID from IAM - Set
Passwordto the secret key from IAM - Confirm the remaining Optional Encoded Parameter, Optional Parameter, and Use HTTP Secure are empty/unchecked.
- In the Advanced Settings tab:
- Set IP address source ⇒ Network
- Set Network ⇒
wan - Set DNS-Server to a different DNS server than the rest of your network (I used
9.9.9.9)- This should be different to avoid DNS caching or any complications with custom hosted DNS serving reverse proxy records
- In the Timer Settings tab, set the timer settings as needed. Note that the “check” vs “force” are different — the “check” timer simply check for a change and update the record if needed; the “force” timer updates the record unconditionally. I used the following:
- Check Interval ⇒ 5
- Check Unit ⇒ minutes
- Force Interval ⇒ 1
- Force Unit⇒ hour
- Error Max Retry Counter ⇒ 0
- Error Retry Interval ⇒ 150
- Error Retry Unit ⇒ seconds
Start the service, and profit!