Self-built DDNS configuration tutorial (dynu)

Domestic aircraft cannot be used

First of all, you need to go to https://www.dynu.com/zh-CN/   (you need to go online scientifically) to register an account of your own. We click on the upper right corner to create an account. The first and last name are optional, and then we will fill in the user name, and we must write down our user name and password for later use. Third-party logins are not recommended. Then we log in. Select Dynamic Domain Name Resolution Service .

After entering, select Add

There are two ways, one is free, and the other you need to put your own domain name (if you have one) to host here. Which one to use depends on your preference, here we use the first one. Write the domain name in front of it casually, and you must remember this domain name. Then we go in and start setting up.

Write the IPv4 address casually, such as 1.2.3.4, feel free to fill in, this A record will be updated at the end, just set the survival time by yourself, or leave the IPv6 and location name blank by default. Then we click Save . At this time, we return to the dynamic domain name resolution list, and the record we just added has appeared in the list

Then log in to your VPS and execute the following command

Debian/Ubuntu :
 
apt-get update
 
apt install curl -y
 
CentOS :
 
yum -y update
 
yum -y install curl
 curl "https://api.dynu.com/nic/update?hostname=example.dynu.com&password=PASSWORD"

Change example.dynu.com to the domain name you just applied for, and PASSWORD to your account password. Then press Enter to execute. It may take a while in the middle, just wait patiently until the output good xxx.xxx.xxx.xxx (as shown in the figure below) At this point, the DDNS update is complete.

Use Crontab to run regularly

Execute the following command

cd ~
 
crontab -e

 Select a text editor, we choose nano here, the system default of CentOS is that vi editor does not need to be selected

Press the arrow keys on the keyboard to position the cursor. The nano editor adds the following line at the end. If it is a vi editor, press i to add it.

*/1 * * * * curl "http://api.dynu.com/nic/update?hostname=example.dynu.com(申請的域名)&password=申請的密碼"  >/dev/null 2>&1 &

after we

The nano editor presses Ctrl+X at the same time, and then presses the Y key to save,

In the vi editor, press ESC first and then press :wq to archive,

Then press Enter to confirm.

Now let's check the status of the scheduled task, enter

Debian/Ubuntu :
 
/etc/init.d/cron status
 
CentOS :
 
/bin/systemctl status crond.service 

If there is a green (not necessarily) Active Running, it means that the scheduled task is set successfully

Guess you like

Origin blog.csdn.net/m0_58606834/article/details/123683704