netboxdns

Go Reference Coverage Go Report Card

netboxdns - provides resolution using Netbox DNS Plugin (netbox-plugin-dns)

Description

The netboxdns plugin provides resolution for zones configured using netbox-plugin-dns.

Depends on netbox-plugin-dns version 1.5.4 or greater.

Validated for netbox >= v4.5.4 and netbox-plugin-dns >= v1.5.4.

The account that the API token is tied to will need the following permissions:

Syntax

Available configuration options:

netboxdns [ZONES...] {
    token TOKEN
    url URL
    timeout DURATION
    fallthrough [ZONES...]
    tls CERT KET CACERT
}

Building

Clone the coredns repository and change into its directory.

git clone https://github.com/coredns/coredns.git
cd coredns

Fetch the plugin and add it to coredns's go.mod file:

go get -u github.com/doubleu-labs/coredns-netbox-plugin-dns

Update plugin.cfg in the root of the directory. The netboxdns declaration should be inserted after cache if you want responses from Netbox to be cached.

# Using sed
sed -i '/^cache:cache/a netboxdns:github.com/doubleu-labs/coredns-netbox-plugin-dns' plugin.cfg
# Using Powershell
(Get-Content plugin.cfg).`
Replace("cache:cache", "cache:cache`nnetboxdns:github.com/doubleu-labs/coredns-netbox-plugin-dns") | `
Set-Content -Path plugin.cfg

Build using make:

make

Or if make is not available, run:

go generate && go build

The coredns binary will be in the root of the project directory, unless otherwise specified by the -o flag.

Contributing

A justfile is provided with commands to help with development. It uses Podman and Podman Compose to run Netbox with the installed plugins in a containerized environment with PostgreSQL and Valkey.

To start the test instance, run:

just instance-start

This will initialize Netbox and wait for it to become healthy, then populate the database with the test dataset.

This can be browsed by visiting http://localhost:9999 with the admin:admin username and password.

To stop the test instance, run:

just instance-stop

To run test and generate coverage the report, run:

just test

To view the coverage report using Go's built-in tool, run:

just coverage

test depends on instance-start and coverage depends on test, so they will be run automatically when just test or just coverage is run.