Dynamic DNS using Alibaba Cloud DNS API

Why We Need a Dynamic DNS solution

What Do We Need

Clone the Repo

Get Your Access Keys from Alibaba Cloud

Setting the Dynamic DNS Updater Script up in the ECS

<?phpdate_default_timezone_set('UTC');include_once 'alicloud-php-updaterecord/V20150109/AlicloudUpdateRecord.php';use Roura\Alicloud\V20150109\AlicloudUpdateRecord;$AccessKeyId     = 'CAmKUmIUGiMO83mS';
$AccessKeySecret = 'CjKaN02Ann9maMmiauusmoGOI7mn';
$updater = new AlicloudUpdateRecord($AccessKeyId, $AccessKeySecret);
$newIp = $_SERVER['REMOTE_ADDR']; // New IP$updater->setDomainName('customnasathome.com');
$updater->setRecordType('A');
$updater->setRR('@');
$updater->setValue($newIp);print_r($updater->sendRequest());

Testing the Updater

Array
(
[RecordId] => 3666544576879860
[RequestId] => F4VDF8A-D2DF-49VV-ER00-458D6918FDDE
)

Securing the Script

.htaccess

AuthType Basic
AuthName "DNS Updater Access"
AuthUserFile /var/www/dyndns-updater/.htpasswd
Require valid-user

.htpasswd

Cron Job

Wrapping Up

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store