Skip to content

Dynamic DNS record update utility for CloudFlare DNS service. Python implemented

License

Notifications You must be signed in to change notification settings

nhymxu/cf-dns-update-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

cf-dns-update-python

Dynamic DNS record update utility for CloudFlare DNS service. Python implement

Requirements

  • Linux/macOS (tested with macOS 10.15.1 & Ubuntu 18.04)
  • Python 3 ( version >= 3.6 is recommended )

Download & Setup

Download

Download code from Release page.

Link here: https://github.com/nhymxu/cf-dns-update-python/releases/latest

Or

clone repo using git:

git clone git@github.com:nhymxu/cf-dns-update-python.git

Create CloudFlare Token

  1. Go to CloudFlare dash
  2. Click open any domain you have
  3. Scroll to bottom, you can see API section from right column.
  4. Click Get your API token
  5. Click Create Token
  6. Enter Token name
  7. On Permissions section. Choose Zone - DNS - Edit
  8. On Zone resource section. Choose Include - All zone or specific zone you want.
  9. Click Continue to Summary
  10. Copy token display on page

Setup CloudFlare Token

Copy file config.ini.sample to current folder with name config.ini

Add CloudFlare token to first section like this

[common]
CF_API_TOKEN = token_key_here

Setup record to update

  1. Look at step 3 on section Create CloudFlare Token
  2. Copy Zone ID
  3. Edit like sample

Notes:

  • @ will be same as base_domain
  • To proxy a record, include it in both records and proxied_records

Auto running

I want my script auto running every x minutes. So I need set up cronjob for it.

From server shell, typing:

crontab -e

And add this line to end of file

*/15 * * * * /opt/cf-dns-update-python/run.sh

This script will run each 15 minutes.

Service get public IP

If you want custom what service to get public IP, you can config in config.ini file

Sample

[common]
CHECK_IP_SERVICE = xxx

where xxx is service name listed below

Name Endpoint
amazonaws https://checkip.amazonaws.com
ifconfig.me https://ifconfig.me/ip
icanhazip https://icanhazip.com/
ipecho https://ipecho.net/plain