Skip to content

This simple scripts are designed to implement DDNS feature using the service Cloudflare.

License

Notifications You must be signed in to change notification settings

ausicle/mikrotik-cloudflare-ddns-scripts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mikrotik-cloudflare-ddns-scripts

This simple scripts are designed to implement DDNS feature using the Cloudflare API.

Requirements and dependences

Scripts work only on RouterOS version 6.44 and above.

Depends on Mikrotik JSON Parser project installed as system script with name JParseFunctions.

Configure

Each script (IPv4 and IPv6) has a configuration area. Just insert your values.

First of all you need your Cloudflare API Token. Create the Cloudflare API Token, with DNS edit permission for your zone. Then grab your token, and follow the instructions. Keep the API Token safe.

You can go to your site's cloudflare dashboard to retrieve zone id, on the URL it is https://dash.cloudflare.com/$zone_id/$domain_name, but DNS Record ID is only possible through REST API.

REST API methods List Zones and List DNS Records. Using any REST client (e.g. HTTPie, or curl), sending a request, you will receive the JSON answer with necessary Zone and DNS Record IDs.

Insert all variables in scripts and install in your RouterOS device.

Get zone id with cURL

Replace $api_token with your api token.

curl --request GET \
  --url https://api.cloudflare.com/client/v4/zones \
  --header "Authorization: Bearer $api_token" \
  --header "Content-Type: application/json"

Get record id with cURL

Get dns record id. Replace $api_token with your api token. And $zone_id with zone id from above.

curl --request GET \
    --url https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records \
    --header "Authorization: Bearer $api_token" \
    --header "Content-Type: application/json"

Tip

You can use jq to prettify json output.

Running

You may add this script to system scheduler as periodically task.

Thanks for using.

About

This simple scripts are designed to implement DDNS feature using the service Cloudflare.

Topics

Resources

License

Stars

Watchers

Forks