Live data from Hacker News

Cloudflare-sync – Tool for using Cloudflare as a dynamic DNS provider

github.com

11–20 of 44 posts

Re: Cloudflare-sync – Tool for using Cloudflare as a dynamic DNS provider

#11

I wrote a little Go tool a few years back that can use your Digital Ocean account as a Dynamic DNS provider. It has been running on my EdgeRouter ever since with a cron job. https://github.com/2bytes/dodns

Nice! Very useful, didn't know this was possible.

Re: Cloudflare-sync – Tool for using Cloudflare as a dynamic DNS provider

#15

This is not very efficient: - It updates the records every 30 seconds even if it doesn't have to. - It has to be run as a daemon, eating memory and CPU time constantly. - only checks one IP service (ipify) I have a more advanced version, which: - you can run as a cron job - only updates the records if the IP address actually changed. - checks multiple IP services (so in case multiple of them going down, it will still…

I'm using this one with Google Cloud, although it only checks IPs using a single provider (otherwise it's pretty much the same as you're describing it):

https://github.com/andreycizov/ddns-gcloud

Re: Cloudflare-sync – Tool for using Cloudflare as a dynamic DNS provider

#16

This is not very efficient: - It updates the records every 30 seconds even if it doesn't have to. - It has to be run as a daemon, eating memory and CPU time constantly. - only checks one IP service (ipify) I have a more advanced version, which: - you can run as a cron job - only updates the records if the IP address actually changed. - checks multiple IP services (so in case multiple of them going down, it will still…

It would also probably be good to use Cloudflare's own ip lookup service, available on every CF website's "/cdn-cgi/trace" page. The only thing is that you need to find a ipv4-only CF website to get the v4 instead of v6.

Or just have the tool open an ipv4 socket when accessing it.

Re: Cloudflare-sync – Tool for using Cloudflare as a dynamic DNS provider

#17
I wrote a similar script that supports any type of record update, not just A, 7 different public IP providers over multiple methods, config via file / env variables / cli arguments, and both DigitalOcean + CloudFlare individually or simultaneously. I use it across my entire fleet of servers, even servers with static public IPs so that I can snapshot them to new boxes and have all my DNS records update automatically.

https://github.com/pirate/bash-utils/blob/master/dns.sh

    Helper script to update a DNS record on multiple providers.
Usage: ./dns.sh --domain=domain.example.com [--get|--set=value] [...options]

Options:

    [domain]               The DNS domain you want to get or set (required)

    --domain=example.com   Same as passing [domain] directly as an argument
    -t=|--type=A           The DNS record type, e.g. A, CNAME, etc. (A default)

    -g|--get               Get the record value (the default)
    -s=|--set=value        Set the record value, e.g. 123.235.324.234 or the
                             special value 'pubip' to use current public ip


    -l=|--ttl=n            Set the record TTL to n seconds (overrides api default)
    -p=|--proxied          Set the record to be proxied through CDN (Cloudflare only)
    -a=|--api=cf,do        List of DNS providers to use, e.g. all (default) or cf,do
    -r=|--refresh=n        Run continusouly every n seconds in a loop
    -w=|--timeout=n        Wait n seconds before aborting and retrying
    
    -c=|--config=file      Path to a dotenv-formatted config file to load
    -e=|--config-prefix=X  Load config vars with prefix X e.g. X_VERBOSE=1

    ...

Re: Cloudflare-sync – Tool for using Cloudflare as a dynamic DNS provider

#19

This is not very efficient: - It updates the records every 30 seconds even if it doesn't have to. - It has to be run as a daemon, eating memory and CPU time constantly. - only checks one IP service (ipify) I have a more advanced version, which: - you can run as a cron job - only updates the records if the IP address actually changed. - checks multiple IP services (so in case multiple of them going down, it will still…

It would also probably be good to use Cloudflare's own ip lookup service, available on every CF website's "/cdn-cgi/trace" page. The only thing is that you need to find a ipv4-only CF website to get the v4 instead of v6.

Accessing the cloudflare IP address directly works.

For example http://1.1.1.1/cdn-cgi/trace

Re: Cloudflare-sync – Tool for using Cloudflare as a dynamic DNS provider

#20
post #19

Earlier quoted context omitted.

It would also probably be good to use Cloudflare's own ip lookup service, available on every CF website's "/cdn-cgi/trace" page. The only thing is that you need to find a ipv4-only CF website to get the v4 instead of v6.

Accessing the cloudflare IP address directly works. For example http://1.1.1.1/cdn-cgi/trace

very groovy, thanks!
Post reply on HN