Skip to content

Instantly share code, notes, and snippets.

@nathan-osman
Created September 9, 2015 20:48
Show Gist options
  • Save nathan-osman/688770de6e53a1844c3e to your computer and use it in GitHub Desktop.
Save nathan-osman/688770de6e53a1844c3e to your computer and use it in GitHub Desktop.
Update a DNS record via an HTTP GET request
// Compile for the current platform with:
// go build dnsupdate.go
// Cross-compile for Windows with:
// GOOS=windows GOARCH=amd64 go build dnsupdate.go
package main
import (
"fmt"
"net/http"
)
// Replace [...] with the correct token for your DNS entry
const updateURL = "https://freedns.afraid.org/dynamic/update.php?[...]"
func main() {
fmt.Println("Updating private DNS entry...")
if _, err := http.Get(updateURL); err != nil {
fmt.Println(err.Error())
} else {
fmt.Println("Private DNS entry updated!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment