Using the Cloudflare API to change DNS records to maximize uptime
MIT License
Using the Cloudflare API to change DNS records to maximize uptime
Necessary data can be passed via environment vairables or CLI flags
api-failover --primary 0.0.0.0,0.0.0.1,0.0.0.2 --backup 0.0.0.3,0.0.0.4,0.0.0.5 --cloudflareapitoken token --cloudflarezoneid CLOUDFLAREZONEID --recordname RECORDNAME
# Is equivalent to
CLOUDFLARE_API_TOKEN="token" CLOUDFLARE_ZONE_ID="zoneid" RECORD_NAME="RECORDNAME" PRIMARY_IPs="0.0.0.0,0.0.0.1,0.0.0.2" BACKUP_IPs="0.0.0.3,0.0.0.4,0.0.0.5" api-failover
# and
docker run -e CLOUDFLARE_API_TOKEN="token" -e CLOUDFLARE_ZONE_ID="zoneid" -e RECORD_NAME="RECORDNAME" -e PRIMARY_IPs="0.0.0.0,0.0.0.1,0.0.0.2" -e BACKUP_IPs="0.0.0.3,0.0.0.4,0.0.0.5" -it --rm ghcr.io/slashtechno/api-failover
For full flag usage, run:
api-failover --help
In some cases, an error may be thrown when the program attempts to ping the specified hosts. The simplest way to alleviate this is to run the program as root or in Docker. For more information, check the Linux section in the pro-bing README
Precompiled releases are build automatically by Github Actions and can be downloaded from the releases page After downloading for the appropriate platform, the program can be run directly
Docker images can either be built locally, or pulled from the Github Container Registry An advantage to running with Docker is that the software is isolated which can reduce the possiblity of errors. In addition, it can increase security. To pull and run, the following commands can be used:
docker pull ghcr.io/slashtechno/api-failover:latest
# If the image isn't pulled manually, the following command will pull it automatically before running
docker run -e CLOUDFLARE_API_TOKEN="token" -e CLOUDFLARE_ZONE_ID="zoneid" -e RECORD_NAME="RECORDNAME" -e PRIMARY_IPs="0.0.0.0,0.0.0.1,0.0.0.2" -e BACKUP_IPs="0.0.0.3,0.0.0.4,0.0.0.5" -it --rm ghcr.io/slashtechno/api-failover
In order to compile locally, Go must be installed
git clone https://github.com/slashtechno/api-failover/
cd api-failover
go install