· 3 years ago · May 08, 2022, 03:30 PM
1Modify the DDNS script and add relevant information
2
3Set up scheduled tasks
4
5
6Connect the domain name to cloudflare
7
8Open cloudflare, log in to your account to add a website and follow the prompts
9
10
11Get Global API Key
12
13Visit https://dash.cloudflare.com/profile to find the Global API Key at the bottom of the page, click View on the right to view the Key, and save it, find the Global API Key at the bottom of the page, click View on the right to view the Key, and save it down
14
15
16Set the second-level domain name for DDNS resolution, the traffic does not pass through the CDN (clouds are grayed out)
17
18Add an A record, for example: hkt.test.com, set Proxy status to DNS only
19
20
21Download DDNS one-click script
22
23curl https://raw.githubusercontent.com/aipeach/cloudflare-api-v4-ddns/master/cf-v4-ddns.sh > /root/cf-v4-ddns.sh && chmod +x /root/cf-v4-ddns.sh
24
25Modify the DDNS script to add your own information
26
27vim cf-v4-ddns.sh
28
29
30# incorrect api-key results in E_UNAUTH error
31# Fill in the Global API Key
32CFKEY=
33
34# Username, eg: user@example.com
35# Fill in the CloudFlare login email
36CFUSER=
37
38# Zone name, eg: example.com
39# Fill in the first-level domain name that needs to be used for DDNS
40CFZONE_NAME=
41
42# Hostname to update, eg: homeserver.example.com
43# Fill in the second-level domain name of DDNS (just fill in the prefix)
44CFRECORD_NAME=
45
46
47Run the script after setting
48
49 ./cf-v4-ddns.sh
50
51Run the script for the first time, the output will display the current IP, enter cloudflare to check to make sure the IP has been changed to the current IP
52
53Set timed tasks (environment centos7)
54
55crontab -e
56
57*/2 * * * * /root/cf-v4-ddns.sh >/dev/null 2>&1