Hacker News new | ask | show | jobs
by nikisweeting 2479 days ago
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

    ...