Ali cloud management API use dynamic domain name resolution ddns

Dynamic DNS,Acronym ddns,It is different from our usual DNS resolution,But it is intended to deal with the kind of no fixed public IP address resolution server。

Typical usage is:Construction of small home broadband server,There is no fixed IP,Want online,In addition to writing scripts mail outside,The only way this can go ddns。

as far as I can tell,The most famous is probably the notoriously unstable and difficult to use the peanut shells。If there is a foreign dynu also very good。

Ali now open cloud API,So we can use Ali cloud API ddns it a self-fulfilling? Natural principle is very simple,Yourself achieve a small client,Then regularly obtain their own IP and external network through the API to modify the corresponding domain name resolution just fine!

of course,Some work has been done in this part of the client (thanks),With python 2 achieve,So,It is cross-platform。

Here we use Ubuntu 16.04 The examples do vps。

First cloned from github project to the local:

And then copy the configuration file to the specified location and edit:

Here,We need to get permission Ali cloud API,Get method is to log on Ali cloud;

  1. Find "Access Keys" to the right of the top bar background Home;
  2. Click the page top right button to create a new Access Key after passing through SMS verification;
  3. The displayed page Access Key ID and Access Key Secret, compared with the required ID and Key。

After obtaining permission to API,We continue to modify the configuration:

Configuration interval Invalid do not control, [DomainRecord1] Is your domain name field,Can be changed to correspond to the name used to distinguish different subdomains only,If you want to do dynamic analysis of multiple subdomains,Then you can write multiple fields。

For this field, domain For your domain,Primary Domain; sub_domain To resolve the dynamic subdomains,Remember created in advance,To resolve to any IP。

For example,,To dynamic analysis home.logcg.com,Then fill in accordance with the foregoing example。

type To resolve records,For example, the A record (case records);MX records。

At last id and value Leave blank,Let the program can be completed on their own。

After editing is completed,You can perform Ubuntu:/opt/aliyun-ddns-client# python ddns.py To run,The first run will get an error [ERROR] You must specify domain record id. It's ok,This is because we id The results of field blank,Get complete program itself,Perform another try:

I went backstage to see the page refresh,Resolve the address has been updated。

Auto Sync

Then,Now we use Ubuntu task management to achieve a dynamic domain name analytic:

We add an additional row at the end of the file contents,enter:

Sentence indicates every minute,Enter the program directory (we previously cloned client directory),And then perform an update program。

All right,At this point it would be our home.logcg.com domain dynamic analysis ✌️

Original article written by Gerber drop-off:R0uter's Blog » Ali cloud management API use dynamic domain name resolution ddns

Reproduced Please keep the source and description link:https://www.logcg.com/archives/1768.html

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Comments

      1. Encounter new problems,,,,

        ubuntu @ ubuntu:/opt/aliyun-ddns-client$ python ddns.py
        Failed to get valid Domain Records Info
        2016-07-08 23:30:14 [ERROR] Failed to match remote domain record for http://www.wixxz.com
        2016-07-08 23:30:14 [ERROR] Failed doing the first time sync for record:DomainRecord1

        Looking for reasons,,,,

  1. Git your Aliyun-DDNS-client application when this stuff in the following error,Bloggers time, then help look yo, My mailbox 3117821@qq.com

    ubuntu @ ubuntu:/opt/aliyun-ddns-client$ python ddns.py
    Traceback (most recent call last):
    File “ddns.py”, line 21, in
    from helper import DDNSHelper
    File “/opt/aliyun-ddns-client/helper.py”, line 20, in
    from utils import DDNSUtils
    File “/opt/aliyun-ddns-client/utils.py”, line 20, in
    import requests
    ImportError: No module named requests

    End

Leave a Reply

Your email address will not be published. Required fields are marked *