Use AliDDNS to deploy fixed domain names for dynamic IP VPS/NAT VPS

Use AliDDNS to deploy fixed domain names for dynamic IP VPS/NAT VPS

AliDDNS tool is a DDNS domain name update tool based on Alibaba Cloud Resolution API. By executing the script, you can quickly update the domain name records on Alibaba Cloud Resolution to achieve the effect of dynamic domain name. In addition, it introduces: using CloudFlare API to deploy fixed domain names for dynamic IP VPS/NAT VPS. CF is recommended, which is simpler!

The following are the installation and usage methods.
1. First, install dependencies:
For CentOS:

 yum install -y wget curl cronie

For Debian 8+:

 apt install -y wget curl cron

For Ubuntu/Debian 7:

 apt-get install -y wget curl cron

2. Download the script, execute and install:

 wget -O /usr/sbin/AliDDNS.sh https://zhujiwiki.com/wp-content/uploads/2018/07/AliDDNS-v2.0.sh chmod +x /usr/sbin/AliDDNS-v2.0.sh /usr/sbin/AliDDNS-v2.0.sh

The startup menu pops up:

 AliDDNS 工具(阿里云云解析修改工具)使用方法(Usage): AliDDNS.sh run 配置并運行工具(如果已有配置將會直接運行) AliDDNS.sh config 僅配置工具AliDDNS.sh clean 清理配置文件及運行環境AliDDNS.sh version 顯示版本信息[Info] 選擇你要使用的功能:配置并運行AliDDNS僅配置AliDDNS清理環境退出輸入數字以選擇: _

Here, we enter 1 (number 1) and press Enter to start the AliDDNS configuration wizard:

 [Info] 請輸入一級域名(比如example.com) (此項必須填寫,查看幫助請輸入“h”):

If you need to set the domain name of AliDDNS to ddns.example.com, please enter example.com here

Breaking it down, it is [ddns]. [example.com]

At the same time, log in to Alibaba Cloud’s cloud resolution service https://dns.console.aliyun.com/, and add a record on the domain name that requires DDNS:

記錄類型:A主機記錄:[請填寫你的二級域名]解析線路:默認記錄值:127.0.0.1 (或者隨便填寫一個IP地址) TTL: [請根據實際需要選擇合適的TTL]同步默認線路:是(勾選)

After completion, press Enter and continue to fill in the secondary domain name:

 [Info] 請輸入二級域名(比如ddns) (此項必須填寫,查看幫助請輸入“h”):

Same as the example above, we enter ddns and press Enter to continue:

 [Info] 請輸入記錄的TTL(Time-To-Live)值: (默認為600,查看幫助請輸入“h”):

If you are using the free version of Alibaba Cloud Analytics, the value range that can be filled in here is: 600~86400;
If you are using the paid version (Enterprise Edition) of Alibaba Cloud Analytics, the value range that can be filled in here is: 1~86400 (depending on the type of product you purchased).

After filling in the form, press Enter to continue:

 [Info] 請輸入阿里云AccessKey ID (此項必須填寫,查看幫助請輸入“h”):

AccessKey ID and AccessKey Secret It is recommended to use the permissions assigned by the sub-user AccessKey (access console RAM)! This is the safest way!

When using the sub-user AccessKey, please assign the following permissions: AliyunDNSReadOnlyAccess (the permission to read-only access Cloud Resolution (DNS)) and AliyunDNSFullAccess (the permission to manage Cloud Resolution (DNS))! It is recommended that users with hands-on ability use sub-user AccessKey!

If you don't know how to operate or want to save trouble, please use the global AccessKey! But you must pay attention at this time! Never disclose your global AccessKey or publish your global AccessKey on the public Internet! This is equivalent to giving your account away for free, and you can also use your Alibaba Cloud account for free! If a leak occurs, please delete the leaked AccessKey immediately!

After filling in the form, press Enter to continue:

 [Info] 請輸入阿里云Access Key Secret (此項必須填寫,查看幫助請輸入“h”):

As above, fill in the AccessKey Secret corresponding to your AccessKey ID. Obtaining your AccessKey Secret is a high-risk account operation. Please prepare your mobile phone to receive the Alibaba Cloud verification code!

After filling in the form, if the new version of AliDDNS 2.0 does not activate the expert mode, it will directly enter the execution process; if the expert mode is activated, please fill in the following parameters based on your understanding! Otherwise please leave it blank!

 [Info] 請輸入獲取本機IP使用的命令(查看幫助請輸入“h”):

Enter the command used to obtain the local IP address. If you don't understand or don't need configuration, please leave it blank and press Enter directly!

 [Info] 請輸入解析使用的DNS服務器(此項必須填寫,查看幫助請輸入“h”):

Enter the nslookup command to resolve the DNS server used. If you don't understand or don't need configuration, please leave it blank and press Enter directly!

After that, the DDNS (test) operation process will automatically start:

[Info] Detected existing configuration, automatically read the existing configuration. If you don't need it, please clear it through the Clean Environment option in the menu.

 [Info] 正在寫入配置文件…… [Info] 正在獲取本機IP…… [Info] 本機IP:... [Info] 正在獲取ddns.example.com 的IP…… [Info] 解析結果:ddns.example.com -> 127.0.0.1 [Info] 正在生成時間戳…… [Info] 獲取到RecordID:* [Info] 正在更新解析記錄…… {"RecordId":"","RequestId":"----"} [Info] 已經更新RecordID:* [Success] DDNS記錄更新成功,新的IP為:...

The final DDNS record update success prompt appears, which means that the DDNS record synchronization is successful. Wait for the DNS resolution to take effect later to complete the DDNS domain name change!

  1. Crontab (scheduled task) deployment tutorial First, execute the command in the command line:
 crontab -e

A prompt will pop up asking which editor to choose. Please choose a text editor according to your preference:

 Select an editor. To change later, run 'select-editor'. /bin/nano /dev/null 2>&1 &

After adding, save and exit.

When the prompt crontab: installing new crontab appears, it means that the crontab has been written successfully. Execute the command to restart the cron process:

For CentOS:

 service crond restart

For Ubuntu/Debian:

 service cron restart

And add Cron to the startup items:

For CentOS:

 chkconfig crond on

For Ubuntu/Debian:

 systemctl enable cron

The deployment of scheduled tasks can be completed.

The full text of this article is reproduced from: https://blog.ilemonrain.com/linux/aliddns-v2.html
Original code: https://github.com/kyriosli/koolshare-aliddns/tree/master/aliddns

<<:  CloudCone: $40/year/512MB memory/100GB SSD space/2TB bandwidth/KVM/Los Angeles

>>:  NameCheap: Spend $5 on G Suite, get $25 free

Recommend

Windows VPS: $2.25/month/3G memory/30GB SSD space/5TB traffic/KVM/Seattle

WindowsVPS, an American hosting provider, has bee...

The US data center with better optimization for China lines

1. Peer1 dedicated Los Angeles data center. Optim...

HostYun 512MB RAM 50Mbps Bandwidth Korea CN2+KT+LG and other KVM VPS Review

Details : HostYun: 17.8 yuan/month/512MB memory/1...

IYUN Global 512MB RAM 200Mbps Bandwidth Los Angeles CN2 GIA KVM VPS Review

Details : IYUN Global: 9.9 yuan/month/512MB memor...

LoveVPS: $7/month/2 CPU/2GB RAM/25GB space/1000GB browsing/KVM

LoveVPS是成立于2011年1月的主機商,僅提供VPS,有SSD VPS、KVM VPS、XE...