Wednesday, March 15, 2023
HomeJavascriptCloudflare automated DNS upgrade for homelab

Cloudflare automated DNS upgrade for homelab

First Off, I enjoy Cloudflare, I believe they have an excellent item, I make use of Cloudflare to handle all my DNS, any person that has a homelab arrangement understands you require to find out a method to maintain Cloudflare IP upgrade if your house IP is transformed, there are lots of wonderful services available yet I enjoy to develop my very own devices, so I produced cloudflaresync

My house laboratory arrangement is a collection of docker-compose documents, whatever is dockerized so this was the noticeable selection, I’m attempting to discover Golang so created in Go, as well as the code is extremely easy, yet taylormade to my requirement.

 variation:  ' 3.4'

     photo:   niradler/cloudflaresync
      -  env

The code is extremely simple, we obtain the arrangement from a collection of env vars, as well as set up a cron job to run every x time to upgrade DNS documents with brand-new IP, I’m likewise utilizing it to develop brand-new documents when a brand-new solution is produced.

 plan primary

 import (


... func  primary() {
err:= godotenv.Load().
 if err!=  nil {
log.Println(" Mistake loading.env documents").
log.Println(" Begin cron", time.Now()).
cronExpression, exist:= os.LookupEnv(" CRON").
 if! exist {
cronExpression = " 0 * * * *"
log.Println(" cron:", cronExpression).
c:= cron.New().
id, err:= c.AddFunc( cronExpression, updateRecords).
 if err!=  nil {
log.Fatal(" cron AddFunc mistake:", err).
log.Println(" cron id:", id).
log.Println(" Cron Information: ", c.Entries()).

 go permanently().

quitChannel:=  make( chan os.Signal,  1).
signal.Notify( quitChannel, syscall.SIGINT, syscall.SIGTERM).
CLOUDFLARE_SUB_DOMAINS = examination, house.
CRON= */ 2 * * * *.


 Running instance for raspberry pi. docker run-- name cloudflaresync-- env CLOUDFLARE_API_TOKEN=<< essential> >-- env CLOUDFLARE_SUB_DOMAINS=<< application, house> >-- env CLOUDFLARE_DOMAIN=<<> >-- reactivate unless-stopped niradler/cloudflaresync: armv7.


Most Popular

Recent Comments