This script can query a website to reveal the client's external IPv4 address, check if any change has occurred, then update a DNS record in Route 53.
There is an extra option to enable checking the IPv6 address of a named interface, which is useful in stateless addressing environments. When adding this configuration, the IAM user permission policy for Route 53 must allow updates to both DNS record types.
Code is minimal and could be expanded easily. I wrote this because there were no good examples in PHP.
- PHP
- curl
- AWS SDK for PHP v3
- Place these files in an existing SDK project, or install the SDK using
composer require aws/aws-sdk-php - Copy the
config-dist.phptoconfig.phpand provide the DNS details. - Copy the
credentials-distto~/.aws/credentialsand provide the AWS keys. - Run like
php -f ddns.phpor cron like*/10 * * * * /usr/bin/php -f /path/to/ddns.php