Skip to content

Instantly share code, notes, and snippets.

@bigheadsmith
Forked from badrianiulian/README.md
Last active January 9, 2023 00:13
Show Gist options
  • Save bigheadsmith/b7bd145be21dd0b9f382babbbeea9685 to your computer and use it in GitHub Desktop.
Save bigheadsmith/b7bd145be21dd0b9f382babbbeea9685 to your computer and use it in GitHub Desktop.
Cloudflare DNS Updater. Multi-zone, multi-record. IPv4 & IPv6 compatible. Bash replacement for ddclient using Cloudflare API4
[Unit]
Description=Cloudflare DDNS service
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/cfupdater/cfupdater.sh
[Install]
WantedBy=multi-user.target
#!/bin/bash
# GET CONFIG PATH
configjson="$( cd "$(dirname "$0")" ; pwd -P )/config.json"
# GET INTERFACE FROM CONFIG FILE
interface=$(jq -r '.interface' $configjson)
# GET AUTH VALUES FROM CONFIG FILE
api_tok=$(jq -r '.api_tok' $configjson)
global_key=$(jq -r '.global_key' $configjson)
auth_email=$(jq -r '.auth_email' $configjson)
# GET IPv4 ADDRESS
ipv4=$(curl -4 -s -m 60 --interface $interface https://wtfismyip.com/text)
# CHECK IPv4 ADDRESS EXISTS
if [ -z "$ipv4" ]; then
ipv4="noipv4"
echo -e "[Cloudflare DDNS] No IPv4 address found for interface $interface! Please check connection and interface in config.json" | systemd-cat -p notice
fi
# GET IPv6 ADDRESS
ipv6=$(curl -6 -s -m 60 --interface $interface https://wtfismyip.com/text)
# CHECK IPv6 ADDRESS EXISTS
if [ -z "$ipv6" ]; then
ipv6="noipv6"
echo -e "[Cloudflare DDNS] No IPv6 address found for interface $interface! Please check connection and interface in config.json" | systemd-cat -p notice
fi
# IF IPv4 & IPv6 NOT FOUND THEN ASSUME NOT CONNECTED TO INTERNET
if [ "$ipv4" == "noipv4" ] && [ "$ipv6" == "noipv6" ]; then
echo -e "[Cloudflare DDNS] No internet connectivity on interface $interface! Please check connection and interface in config.json" | systemd-cat -p crit
exit 1
fi
# MAKE AUTH_HEADERS
if [ -z "$api_tok" ]; then
declare -a auth_headers=('-H' "X-Auth-Email: $auth_email" '-H' "X-Auth-Key: $global_key" '-H' "Content-Type: application/json")
else
declare -a auth_headers=('-H' "Authorization: Bearer $api_tok" '-H' "Content-Type: application/json")
fi
# GET ALL ZONES FROM API
api_zones=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones" "${auth_headers[@]}")
# CHECK NO ERROR WITH AUTH_HEADERS
if [[ $api_zones = *"\"code\":6003"* ]]; then
echo -e "[Cloudflare DDNS] Unknown Api Token, Global API Key or Email! Check config.json" | systemd-cat -p crit
exit 1
fi
# GET ALL ZONES FROM CONFIG FILE
declare -a config_zones=($(jq -r '.zones[] | .zone' $configjson))
# CHECK CONFIG ZONES LOADED
lenz=${#config_zones[@]}
if [ "$lenz" == 0 ]; then
echo -e "[Cloudflare DDNS] No Zones in config file! Check config.json" | systemd-cat -p crit
exit 1
fi
# LOOP OVER CONFIG ZONES
for (( z=0; z < $lenz; z++ ))
do
# CHECK CONFIG ZONE EXISTS ON CLOUDFLARE
config_zone_name=${config_zones[$z]}
api_zone_id=$(echo $api_zones | jq -r --arg zone $config_zone_name '.result[] | select(.name==$zone) | "\(.id)"')
if [ "$api_zone_id" == "" ]; then
echo -e "[Cloudflare DDNS] Zone $config_zone_name invalid! Check spelling in config.json or that it exists on your Cloudflare account" | systemd-cat -p crit
continue
fi
# GET ALL RECORDS FOR CONFIG ZONE
declare -a config_records=($(jq -r --arg zone $config_zone_name '.zones[] | select(.zone==$zone) | .records[] | .record + " " + .type' $configjson))
# CHECK CONFIG RECORDS LOADED
lenr=${#config_records[@]}
if [ "$lenr" == 0 ]; then
echo -e "[Cloudflare DDNS] No records in config file for ${config_zones[$z]}! Check config.json" | systemd-cat -p crit
continue
fi
# GET ALL API RECORDS FOR CONFIG ZONE
api_records=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$api_zone_id/dns_records" "${auth_headers[@]}")
# LOOP OVER CONFIG RECORDS
for (( r=0; r < $lenr; r++ ))
do
# CHECK IF CONFIG RECORD IS ROOT OR SUBDOMAIN
if [ "${config_records[$r]}" == "@" ]; then
config_record_name=$config_zone_name
else
config_record_name="${config_records[$r]}.$config_zone_name"
fi
r=$(( $r + 1 ))
type=${config_records[$r]}
# SET CURRENT RECORD TYPE TO CHECK
if [ "$type" == "A" ]; then
# FOR A RECORDS, CHECK IPv4 AVAILABLE
if [ "$ipv4" == "noipv4" ]; then
echo "[Cloudflare DDNS] Warning! No IPv4 detected. Cannot update A (IPv4) record for $config_record_name" | systemd-cat -p crit
continue
fi
ip=$ipv4
elif [ "$type" == "AAAA" ]; then
# FOR AAAA RECORDS, CHECK IPv6 AVAILABLE
if [ "$ipv6" == "noipv6" ]; then
echo "[Cloudflare DDNS] Warning! No IPv6 detected. Cannot update AAAA (IPv6) record for $config_record_name" | systemd-cat -p crit
continue
fi
ip=$ipv6
else
echo "[Cloudflare DDNS] Warning! Record type \"$type\" not valid. Check config.json" | systemd-cat -p crit
continue
fi
# CHECK CONFIG RECORD EXISTS ON CLOUDFLARE
api_record_id=$(echo "$api_records" | jq -r --arg record $config_record_name --arg type $type '.result[] | select(.name==$record and .type==$type) | "\(.id)"')
if [ "$api_record_id" == "" ]; then
echo -e "[Cloudflare DDNS] Record $config_record_name invalid! Check spelling in config.json or that it exists on your Cloudflare account" | systemd-cat -p crit
continue
fi
# GET API RECORD IP ADDRESS
api_record_ip=$(echo "$api_records" | jq -r --arg id $api_record_id '.result[] | select(.id==$id) | "\(.content)"')
# CHECK IF API RECORD IP IS DIFFERENT TO CURRENT IP
if [ "$ip" == "$api_record_ip" ]; then
echo "[Cloudflare DDNS] IP ($ip) for record $config_record_name has not changed." | systemd-cat -p notice
continue
else
proxied=$(echo "$api_records" | jq -r --arg id $api_record_id '.result[] | select(.id==$id) | "\(.proxied)"')
ipupdate=$(curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/$api_zone_id/dns_records/$api_record_id" "${auth_headers[@]}" --data "{\"type\":\"$type\",\"name\":\"$config_record_name\",\"content\":\"$ip\",\"proxied\":$proxied}")
fi
# CHECK STATUS OF UPDATE
case "$ipupdate" in
*"\"success\":false"*)
echo -e "[Cloudflare DDNS] Update failed for $config_record_name. DUMPING RESULTS:\n$ipupdate" | systemd-cat -p err;;
*)
echo "[Cloudflare DDNS] $type record for $config_record_name synced to $ip" | systemd-cat -p notice;;
esac
done
done
[Unit]
Description=Run cfupdater.service every fifteen minutes
[Timer]
OnCalendar=*:0/15
[Install]
WantedBy=timers.target
# Cloudflare DDNS bash client with systemd
This is a bash script to act as a Cloudflare DDNS client, useful replacement for ddclient.
# Requirements
- curl
- jq
# How to use?
1) Move `cfupdater.sh` to `/usr/local/bin/cfupdater`.
```
mkdir -p /usr/local/bin/cfupdater && mv cfupdater.sh /usr/local/bin/cfupdater
```
2) Make `cfupdater.sh` executable
```
chmod +x /usr/local/bin/cfupdater/cfupdater.sh
```
3) Edit config in config.json
```
# Interface to get IP address for (use ifconfig to find interface name)
"interface": "eth0"
# Create an API Token for DNS updates only (more secure than Global Key)
# Leave empty to use Global API Token
"api_tok": "XXXXXXXXXXXXXXXXXXXX"
# OR use Global API Key (less secure) and Cloudflare login email address
"global_key": "XXXXXXXXXXXXXXXXXXXX",
"auth_email": "test@example.com"
# Zones and records to update.
# Use "@" record to update base domain IP address
# Record type A for IPv4 or AAAA for IPv6
# Must have comma (,) after closing } each zone and record except last
"zones" : [
{
"zone" : "example.com",
"records" : [
{ "record" : "@", "type" : "A" },
{ "record" : "www", "type" : "A" },
{ "record" : "www", "type" : "AAAA" }
]
},
{
"zone" : "example2.com",
"records" : [
{ "record" : "sub1", "type" : "A" },
{ "record" : "sub1", "type" : "AAAA" },
{ "record" : "sub2", "type" : "A" }
]
}
]
```
4) Move config to **the same location as cfupdater.sh**
```
mv config.json /usr/local/bin/cfupdater
```
5) Create a systemd service unit at `/etc/systemd/system/`, `cfupdater.service` is shown as an example.
```
mv cfupdater.service /etc/systemd/system/
```
6) Create a systemd timer unit at **the same location of the service unit**, `cfupdater.timer` is shown as an example.
```
mv cfupdater.timer /etc/systemd/system/
```
7) Enable and start systemd service
```
systemctl enable cfupdater.timer && systemctl start cfupdater.timer
```
8) Output can be seen by typing
```
journalctl -f
```
# Note
The default `cfupdater.timer` is set to execute the script **every fifteen minutes**.
The initial five minutes was modified because the script was heavy-loading the remote IP detector.
Please keep in mind not to spam the API or you will be rate limited.
A quote from Cloudflare FAQ:
> All calls through the Cloudflare Client API are rate-limited to 1200 every 5 minutes.
>
> -- https://support.cloudflare.com/hc/en-us/articles/200171456
{
"interface": "eth0",
"api_tok": "XXXXXXXXXX",
"global_key": "XXXXXXXXXX",
"auth_email": "CLOUDFLARE EMAIL ADDRESS",
"zones" : [
{
"zone" : "example.com",
"records" : [
{ "record" : "@", "type" : "A" },
{ "record" : "www", "type" : "A" },
{ "record" : "www", "type" : "AAAA" }
]
},
{
"zone" : "example2.com",
"records" : [
{ "record" : "sub1", "type" : "A" },
{ "record" : "sub1", "type" : "AAAA" },
{ "record" : "sub2", "type" : "A" }
]
}
]
}
@bigheadsmith
Copy link
Author

Thanks to @badrianiulian for getting the script from @lifehome to update IPv4 and IPv6 at the same time as well as multiple records, and @minhazulOO7 for getting the Zone ID from the zone name via the API.
I have updated to use the Global API Key or a generated API Token.
Next I will look at updating multiple records from multiple zones.

@minhazulOO7
Copy link

Thanks to @badrianiulian for getting the script from @lifehome to update IPv4 and IPv6 at the same time as well as multiple records, and @minhazulOO7 for getting the Zone ID from the zone name via the API.
I have updated to use the Global API Key or a generated API Token.
Next I will look at updating multiple records from multiple zones.

Welcome! 😃 Really liked your API Token method 👍 . I didn't added Multiple Records feature because there is a proxy option in Cloudlflare which needs to be specific for each domain or sub-domain. Will update my gist If I find any solution.

@bigheadsmith
Copy link
Author

bigheadsmith commented Aug 5, 2019

@minhazulOO7 I'm pretty sure that's what the lines below are doing, though I might be wrong

local oldproxied=$(echo "$record" | grep -Po '(?<="type":"'$record_type'","name":"'$2'","content":"'$oldip'","proxiable":'$oldproxiable',"proxied":)[^,]' | head -1)
local oldttl=$(echo "$record" | grep -Po '(?<="type":"'$record_type'","name":"'$2'","content":"'$oldip'","proxiable":'$oldproxiable',"proxied":'$oldproxied',"ttl":)[^,]
' | head -1)

It looks like it checks that the IP/record is a proxiable, then checks the current state (grey or orange cloud). The updated record is then set to match the current proxy state.

@minhazulOO7
Copy link

I am not talking about the code. The code is alright. If I want to check proxy status then I have to make an API call. Which is inefficient IMO. That's why didn't do that. And that's why in my script all of the id's and ip needs to be stored locally. Less API call, more robust, more faster.

@bigheadsmith
Copy link
Author

Right got you. Yes I agree it would be better to be able to retrieve the required info with less API calls. I will continue looking into it and see what I come up with.
Would be appreciated if you let me know if you ever work something out

@minhazulOO7
Copy link

Sure! I am doing some testing on store everything locally. Those contents will be updated if there's any slight change. Will knock you.

@bigheadsmith
Copy link
Author

@minhazulOO7 I've played around a little and now have a script to update all my of dns records in all of my zones and thought you might want to see it.
It uses one api call to get all zones, one api call per zone to get all of its dns records, then one api call per required dns update.
I'm sure it could do with some tidying up, be more efficient and needs testing for how it handles errors, but it works for what I need.
Used jq json filter instead of grep as I really didn't know how to get that to work how I needed, whereas I found jq a bit easier to understand

@minhazulOO7
Copy link

minhazulOO7 commented Aug 9, 2019

@minhazulOO7 I've played around a little and now have a script to update all my of dns records in all of my zones and thought you might want to see it.
It uses one api call to get all zones, one api call per zone to get all of its dns records, then one api call per required dns update.
I'm sure it could do with some tidying up, be more efficient and needs testing for how it handles errors, but it works for what I need.
Used jq json filter instead of grep as I really didn't know how to get that to work how I needed, whereas I found jq a bit easier to understand

Yeah, really liked your work around 👍 . To update multiple zone records, currently I am using multiple scripts in one service. It works without any issue or error. I will post my work around of making everything available locally (which is really tricky). Less API call, more reliable.

@minhazulOO7
Copy link

It uses one api call to get all zones, one api call per zone to get all of its dns records, then one api call per required dns update.

Now this will be NIGHTMARE for me. I have multiple zones. It's like 1 + 1(n) + 1(n) API calls. So lets say, 1 + 1(10) + 1(50). At that time we need some efficient way to update all of the record. This will be WAY TOO MUCH API TAXING and ultimately Cloudflare will block my IP.

@bigheadsmith
Copy link
Author

bigheadsmith commented Aug 9, 2019 via email

@minhazulOO7
Copy link

minhazulOO7 commented Aug 9, 2019

I agree with you. Luckily I don't have that many zones. I'm open to alternatives, but like I said this works for me right now in the way I want it to and it's been kind of fun to do so far too

On Fri, 9 Aug 2019, 18:41 Syed Mohammad Minhazul Islam, < @.***> wrote: It uses one api call to get all zones, one api call per zone to get all of its dns records, then one api call per required dns update. Now this will be NIGHTMARE for me. I have multiple zones. It's like 1 + 1(n) + 1(n) API calls. So lets say, 1 + 1(10) + 1(50). At that time we need some efficient way to update all of the record. This will be WAY TOO MUCH API TAXING and ultimately Cloudflare will block my IP. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://gist.github.com/b7bd145be21dd0b9f382babbbeea9685?email_source=notifications&email_token=ABVS437SBHZS7YLAWLCXPQTQDWT4HA5CNFSM4IJJGBX2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFWY22#gistcomment-2994605, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVS436J77F25GYEC3R7HWDQDWT4HANCNFSM4IJJGBXQ .

Edit: I manage my whole network using MikroTik. I am a network engineer (noob).

For 3-5 zones your work around is more than enough. Will be moving to static IP soon. Managing this much zones with dynamic IP is really tiresome and PITA! 🤣 Will let you know if I make any changes to my script.

@bigheadsmith
Copy link
Author

I agree with you. Luckily I don't have that many zones. I'm open to alternatives, but like I said this works for me right now in the way I want it to and it's been kind of fun to do so far too

On Fri, 9 Aug 2019, 18:41 Syed Mohammad Minhazul Islam, < @.***> wrote: It uses one api call to get all zones, one api call per zone to get all of its dns records, then one api call per required dns update. Now this will be NIGHTMARE for me. I have multiple zones. It's like 1 + 1(n) + 1(n) API calls. So lets say, 1 + 1(10) + 1(50). At that time we need some efficient way to update all of the record. This will be WAY TOO MUCH API TAXING and ultimately Cloudflare will block my IP. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://gist.github.com/b7bd145be21dd0b9f382babbbeea9685?email_source=notifications&email_token=ABVS437SBHZS7YLAWLCXPQTQDWT4HA5CNFSM4IJJGBX2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFWY22#gistcomment-2994605, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVS436J77F25GYEC3R7HWDQDWT4HANCNFSM4IJJGBXQ .

Edit: I manage my whole network using MikroTik. I am a network engineer (noob).

For 3-5 zones your work around is more than enough. Will be moving to static IP soon. Managing this much zones with dynamic IP is really tiresome and PITA! 🤣 Will let you know if I make any changes to my script.

Yes most servers I have are using static IPs but I have some at family member's houses where the ISP will not give static so this works well.
I recently read up on MicroTik. Might be the next thing I play around with when my router packs up. I've a full on noob just picking things up as I go along when I need to. Sometimes I can apply it to my work sometimes its just as a hobby to have something to keep me busy

@minhazulOO7
Copy link

I agree with you. Luckily I don't have that many zones. I'm open to alternatives, but like I said this works for me right now in the way I want it to and it's been kind of fun to do so far too

On Fri, 9 Aug 2019, 18:41 Syed Mohammad Minhazul Islam, < @.***> wrote: It uses one api call to get all zones, one api call per zone to get all of its dns records, then one api call per required dns update. Now this will be NIGHTMARE for me. I have multiple zones. It's like 1 + 1(n) + 1(n) API calls. So lets say, 1 + 1(10) + 1(50). At that time we need some efficient way to update all of the record. This will be WAY TOO MUCH API TAXING and ultimately Cloudflare will block my IP. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://gist.github.com/b7bd145be21dd0b9f382babbbeea9685?email_source=notifications&email_token=ABVS437SBHZS7YLAWLCXPQTQDWT4HA5CNFSM4IJJGBX2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFWY22#gistcomment-2994605, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVS436J77F25GYEC3R7HWDQDWT4HANCNFSM4IJJGBXQ .

Edit: I manage my whole network using MikroTik. I am a network engineer (noob).
For 3-5 zones your work around is more than enough. Will be moving to static IP soon. Managing this much zones with dynamic IP is really tiresome and PITA! rofl Will let you know if I make any changes to my script.

Yes most servers I have are using static IPs but I have some at family member's houses where the ISP will not give static so this works well.
I recently read up on MicroTik. Might be the next thing I play around with when my router packs up. I've a full on noob just picking things up as I go along when I need to. Sometimes I can apply it to my work sometimes its just as a hobby to have something to keep me busy

Great! Try to learn CCNA (Cisco) and MTCNA (MikroTik) course. Will be enough for basic networking knowledge.

@minhazulOO7
Copy link

Also one thing to point you out, that is, if any of the record is not changed then loop will not work. This loop will only check if every one of the record is changed. Suppose you need to update 3 records in your zone. Now first record was changed so updated it, but second record was not changed so the loop will stop here! It will not check for the next record! Whereas third record needs to be updated! I have tried this loop before but it does not works.

@bigheadsmith
Copy link
Author

Also one thing to point you out, that is, if any of the record is not changed then loop will not work. This loop will only check if every one of the record is changed. Suppose you need to update 3 records in your zone. Now first record was changed so updated it, but second record was not changed so the loop will stop here! It will not check for the next record! Whereas third record needs to be updated! I have tried this loop before but it does not works.

Strange. I have tested by changing the IP addresses for some records in two zones to a random IP on Cloudflare dashboard. The log below shows that all 22 records are checked across all 8 zones with the required records being updated:

[Cloudflare DDNS] A record for example1.co.uk synced to xxx.xxx.xxx.xxx
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example1.co.uk has not changed.
[Cloudflare DDNS] A record for example2.co.uk synced to xxx.xxx.xxx.xxx
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example2.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub1.example2.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub.sub1.example2.co.uk has not changed.
[Cloudflare DDNS] A record for sub2.example2.co.uk synced to xxx.xxx.xxx.xxx
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub3.example2.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub4.example2.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example3.info has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example3.info has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example4.me.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example4.me.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example5.com has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example5.com has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example6.me has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example6.me has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example7.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example7.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub1.example7.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example8.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example8.co.uk has not changed.

@minhazulOO7
Copy link

Also one thing to point you out, that is, if any of the record is not changed then loop will not work. This loop will only check if every one of the record is changed. Suppose you need to update 3 records in your zone. Now first record was changed so updated it, but second record was not changed so the loop will stop here! It will not check for the next record! Whereas third record needs to be updated! I have tried this loop before but it does not works.

Strange. I have tested by changing the IP addresses for some records in two zones to a random IP on Cloudflare dashboard. The log below shows that all 22 records are checked across all 8 zones with the required records being updated:

[Cloudflare DDNS] A record for example1.co.uk synced to xxx.xxx.xxx.xxx
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example1.co.uk has not changed.
[Cloudflare DDNS] A record for example2.co.uk synced to xxx.xxx.xxx.xxx
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example2.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub1.example2.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub.sub1.example2.co.uk has not changed.
[Cloudflare DDNS] A record for sub2.example2.co.uk synced to xxx.xxx.xxx.xxx
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub3.example2.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub4.example2.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example3.info has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example3.info has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example4.me.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example4.me.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example5.com has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example5.com has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example6.me has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example6.me has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example7.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example7.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record sub1.example7.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record example8.co.uk has not changed.
[Cloudflare DDNS] IP (xxx.xxx.xxx.xxx) for record www.example8.co.uk has not changed.

Nice! Maybe there was some coding error in my end. Glad to see it works as intended.

@minhazulOO7
Copy link

Also do you removed proxied value? Because by default Cloudflare sets it to true. Some of my domains needs to be DNS only. That's why can not remove proxied value.

@bigheadsmith
Copy link
Author

Also do you removed proxied value? Because by default Cloudflare sets it to true. Some of my domains needs to be DNS only. That's why can not remove proxied value.

Maybe Cloudflare have changed how they do this. I have a combination of proxied and DNS only and the proxied setting is not changed on any records from what it is already set as on the Cloudflared dashboard.
For example, the two records that got updated in the log above are DNS only and have remained as DNS only after the IP sync

@minhazulOO7
Copy link

Also do you removed proxied value? Because by default Cloudflare sets it to true. Some of my domains needs to be DNS only. That's why can not remove proxied value.

Maybe Cloudflare have changed how they do this. I have a combination of proxied and DNS only and the proxied setting is not changed on any records from what it is already set as on the Cloudflared dashboard.
For example, the two records that got updated in the log above are DNS only and have remained as DNS only after the IP sync

Whoa! Let me check it! Will knock you ASAP!

@minhazulOO7
Copy link

NOPE!
Just tried out. Now it's reversed! If I use this, {\"id\":\"$zone_id\",\"type\":\"$record_type\",\"name\":\"$record_name\",\"content\":\"$cur_ip\",\"proxied\":$proxied_value}
then proxied value gets placed as the variable value. But if I use this,
{\"id\":\"$zone_id\",\"type\":\"$record_type\",\"name\":\"$record_name\",\"content\":\"$cur_ip\"}
then proxied value gets placed as DNS only. Previously Cloudflare sets it to Proxied.

@bigheadsmith
Copy link
Author

NOPE!
Just tried out. Now it's reversed! If I use this, {\"id\":\"$zone_id\",\"type\":\"$record_type\",\"name\":\"$record_name\",\"content\":\"$cur_ip\",\"proxied\":$proxied_value}
then proxied value gets placed as the variable value. But if I use this,
{\"id\":\"$zone_id\",\"type\":\"$record_type\",\"name\":\"$record_name\",\"content\":\"$cur_ip\"}
then proxied value gets placed as DNS only. Previously Cloudflare sets it to Proxied.

Good spot, thanks! I've added a line to get current proxied value and use in the update to stop it from changing

@minhazulOO7
Copy link

No prob! 😉

@minhazulOO7
Copy link

minhazulOO7 commented Aug 10, 2019

Tried API Token method. It's still in BETA that's why encountered with many bugs and glitches. Also it's not as fast as Global API method. Sometime it's unable to fetch JSON data. For me it's too much unreliable. I am sticking with Global API method for now. It will be a nice security measure after it finishes BETA phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment