As I build more and more Pi-based systems, I find the need to add management scripts for accessing SSH, OpenVPN, and all kinds of other tools. This leads me to version 4 of the CloudFlare Dynamic DNS AutoIP updater script. It’s now hosted on GitHub.
Pulling off of GitHub:
Create a private Dynamic DNS using the CloudFlare API with this script.
If you have a domain registered at CloudFlare, you can use this script to update the IP of the subdomain with a specific computer. The computer will get its IP address and send the information to CloudFlare using the API.
This script creates 3 files:
- an initializing script that creates and runs everything: cf_ip_script_creator.sh
- a script that gets all the CF details from you: cf_ip_updater_creator.sh
- a script that updates the subdomain IP address: cf_ip_updater.sh
Put the 3rd script (cf_ip_updater.sh) into a cron job to run every 5 or 15 minutes or so so that you can use access your system anywhere.
sudo crontab -e */10 * * * * nice -n 16 /home/scripts/cf_ip_updater.sh
- log into your computer anytime with SSH
- run a portable OpenVPN server
- keep your blog server private by using CloudFlare caching
- whatever you can think of
- if you fail to successfully run the script, the cat commands that append text to existing commands will force you to delete the create scripts (cf_ip_updater.sh, cf_ip_updater_creator.sh) before you run the initializing script (cf_ip_script_creator.sh) again.
- FULLDOMAIN cloudflare.com (your registered domain name)
- SUBDOMAIN web.cloudflare.com (your subdomain linked to your system’s IP address)
- EMAIL [email protected] (your account name)
- KEY 9a7806061c88ada191ed06f989cc3dac (your CloudFlare API key details)
- FILEPATH /home/path (where you want the script to be)
wget https://raw.githubusercontent.com/tgmgroup/Cloudflare-Subdomain-AutoIP-Updater/master/cf_ip_script_creator.sh chmod +X cf_ip_script_creator.sh sudo bash cf_ip_script_creator.sh
- The jq command requires the jq package (sudo apt install jq)
- The dig command requires dnsutils (Debian) or bind-utils (Cent-OS) (sudo apt install dnsutils)
- http://torb.at/cloudflare-dynamic-dns (the base script creator, but I think the site is down)