Dynamic DNS with CloudFlare

This is a simple hack I found for my self to have a “Dynamic DNS” for my home IP.

I’m using CloudFlare as my name server to manage the zone file for my domain, And one of the nice things about FC is that they have nice API to manage your account. One of the options this API provides is the capability to update you DNS entries in the Zone.

Get your token

For all the action with the API you’ll 3 thinks, your privet token (called tkn in the API),  email and the action you like to perform.

You can find your token under your Account page

DNS Record ID

Next you’ll need to find the action you like to perform, in my case is to edit the zone file. which is under the “DNS Record Management” -> rec_edit menu, but for using this action you will need the ID number for the recored you like to change, and for that you will need to use “rec_load_all” action.


The output will be in a JSON format, and the part you are looking for will look similar to this,

Edit/Update the DNS record

Now that you have the ID for the record you like to change, it’s a matter of a simple curl command,

This command will update the IP to for test.example.com entery.

Automate the update process

To automate the process, i have a cron job which runs every 5 minutes, and query my external IP and compare it to the resolved IP form my DNS.


Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *