Categorygithub.com/axllent/dnsmonitor
modulepackage
0.0.0-20230111023235-ea5901386fe8
Repository: https://github.com/axllent/dnsmonitor.git
Documentation: pkg.go.dev

# README

DNSMonitor - A simple DNS monitor written in go

Go Report Card

DNSMonitor is a small commandline utility which queries a DNS server for a specific hostname(s) records on a regular interval, optionally alerting you (Gotify) on any DNS change.

Features

  • Defaults to the network-configured DNS, however a separate DNS server can be specified
  • Polling interval (default every 5 minutes)
  • Supports querying of A, MX, CNAME, TXT & NS records (see usage)
  • Optionally send update alerts to Gotify

Usage examples

dnsmonitor www.example.com

Monitor the A records of www.example.com on a 5-minute interval.

dnsmonitor mx:example.com

Monitor the MX records of example.com on a 5-minute interval.

dnsmonitor ns:example.com txt:example.com www.example.com

Monitor the NS & TXT records of example.com, and the A records of www.example.com on a 5-minute interval.

dnsmonitor -d 1.1.1.1 example.com -i 10

Monitor the A records of example.com on a 10-minute interval using the DNS server on 1.1.1.1.

See dnsmonitor -h for all options.

Notifications

Currently sending notifications to Gotify is supported.

Create a default configuration file in ~/.config/dnsmonitor.json or use the -c flag to spefify an alternative configuration file and set the values:

Gotify

Create a new App on your gotify instance which will generate a unique token.

{
  "gotify_server":"<https://your-gotify-server/>",
  "gotify_token":"<token>"
}

Installing

Multiple OS/Architecture binaries are supplied with releases. Extract the binary, make it executable, and move it to a location such as /usr/local/bin.

Updating

DNSMonitor comes with a built-in self-updater:

dnsmonitor -u

Instaling from source

Go >= 1.11 required:

go get github.com/axllent/dnsmonitor

# Functions

CustomDialer allows a custom DNS server to be set.
DNS2String returns an IP slice as a string, or unresolved for return / output.
Equal compares two slices.
HomeDir returns the user's home directory.
Lookup will do a DNS lookup and return an sorted array of results.
NotifyGotify messages gotify.
SendNotifications will send a notification to all registered apps.

# Structs

Config struct.
Domain struct.