quang4dev

Config DDnS on Linux server with Cloudflare

May 8th, 2022 (edited)
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.65 KB | None | 0 0
  1. #Modify the DDNS script and add relevant information
  2.  
  3. #Set up scheduled tasks
  4. #Connect the domain name to cloudflare
  5.  
  6. #Open cloudflare, log in to your account to add a website and follow the prompts
  7. #Get Global API Key
  8.  
  9. #Visit 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
  10.  
  11. #Set the second-level domain name for DDNS resolution, the traffic does not pass through the CDN (clouds are grayed out)
  12. #Add an A record, for example: hkt.test.com, set Proxy status to DNS only
  13.  
  14. #Download DDNS one-click script
  15. curl 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
  16.  
  17. #Modify the DDNS script to add your own information
  18. vim cf-v4-ddns.sh
  19.  
  20. # incorrect api-key results in E_UNAUTH error
  21. # Fill in the Global API Key
  22. CFKEY=
  23.  
  24. # Username, eg: [email protected]
  25. # Fill in the CloudFlare login email
  26. CFUSER=
  27.  
  28. # Zone name, eg: example.com
  29. # Fill in the first-level domain name that needs to be used for DDNS
  30. CFZONE_NAME=
  31.  
  32. # Hostname to update, eg: homeserver.example.com
  33. # Fill in the second-level domain name of DDNS (just fill in the prefix)
  34. CFRECORD_NAME=
  35.  
  36. #Run the script after setting
  37. ./cf-v4-ddns.sh
  38.  
  39. #Run 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
  40.  
  41. #Set timed tasks (environment centos7)
  42. crontab -e
  43.  
  44. */2 * * * * /root/cf-v4-ddns.sh >/dev/null 2>&1
Add Comment
Please, Sign In to add comment