Last update at :2024-07-03,Edit by888u
In the past few days, I have come across a server with a dynamic IP address, because I have heard of it before but have never actually used it. Generally, we use dynamic IP servers to build websites, because some websites need to change IP, but most of them should be that some projects need to use different IPs, and the total cost of the server with a fixed IP address is relatively large, and the dynamic IP server The average cost is lower.
I was originally researching how to dynamically change the server IP, but I didn't figure it out. When I asked about the official tutorial, I saw that there is a way to bind your own fixed domain name settings to a dynamic IP address. Here it is Record it first. I have not researched the official methods, but I found methods mentioned in scripts on the Internet that can be achieved.
First, prepare script information
Script address: https://soft.laozuo.org/scripts/ddns.sh
I found the source of the script from the Internet. There are several sources. It seems that more sources come from here: https://zhujiwiki.com/usr/uploads/2018/07/CloudFlareDDNS/cloudflare-update- record.sh. So thank you to this classmate for providing it.
Don’t rush to upload the script when we get it. Let’s prepare the data first and then replace it.
Second, obtain API information from CloudFlare
Get the address: https://dash.cloudflare.com/profile
Log in to our CF account, then open the address above and drag it to the bottom to see the Global API Key, then click on the VIEW behind to view it, and get the API KEY and drop it to the corresponding location above us.
At the same time, auth_email is the email account of our CF account, and zone_name is the main domain name we add the domain name to resolve in CF. Of course, we need to add the fixed domain name to CF. record_name is the domain name we need to implement dynamic IP. Here I will give an example and set it to ddns.laozuo.org.
At the same time, we need to implement fixed domain name resolution for dynamic IP.
Do not parse the fixed IP, parse 127.0.0.1 directly, because it will be done automatically later.
Third, whether the test is effective
Here we throw the modified script to the server and then execute the command.
bash ddns.sh
If you can see the IP, it means there is nothing wrong with the configuration. Let’s take a look at the set fixed domain name and PING test to see if it resolves to the currently assigned dynamic IP address. It's ok after the snail test.
Fourth, how to achieve automation
Because this netizen does not know how to play with the dynamic IP server at present, it is not clear how to implement dynamic IP. Some changes can be made by redialing or restarting, but this is not clear. Therefore, we have not yet tested how to automate the implementation. According to existing methods, we can automatically add the above script to the timing file, so that automated changes can be achieved.
For example, if we set whether to execute the script every five minutes or ten minutes, the IP address will change once.
1. Timing configuration
crontab -e
2. Set cycle
*/10 * * * * bash /root/ddns.sh
Add the script to the last line of the custom file to implement changes every 10 minutes.
Fifth, other script methods
Other scripts: https://soft.laozuo.org/scripts/cf-ddns.sh
Snail originally used this script, which is provided by the official, but it has not been able to obtain the CFID. It is not clear where the problem lies. We will talk about it later when we have time, and record it first.
In this way, we can use the above method to bind a server with a dynamic IP to a fixed domain name to achieve the dynamic IP effect of a fixed domain name.
Recommended site search: view IP address, registered domain name, rented server, US multi-IP site group vps, Taiwan server, la domain name, Guangdong virtual host, icp filing query network, free stable space, free foreign space,
发表评论