dnsguard

package
v4.24.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dnsguard is a DNS forwarder that checks every name a workload looks up against the feeds' domain indicators.

It catches what the egress proxy cannot: software that ignores HTTPS_PROXY still resolves names, and a lookup of a command-and-control domain is the earliest sign of a compromise. Point the workload's resolver at it (/etc/resolv.conf, the task's dnsServers, a pod's dnsConfig).

A refused lookup answers NXDOMAIN, which every client handles. Anything the guard cannot parse is forwarded untouched: it fails open like the proxies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpstreamFromResolvConf

func UpstreamFromResolvConf(body string) string

UpstreamFromResolvConf reads the first nameserver in a resolv.conf, so the guard forwards to whatever the host used before it was put in front.

Types

type Guard

type Guard struct {
	// Upstream is the resolver lookups go to, host:port.
	Upstream string
	Rules    func() *engine.Set
	Verdicts *decide.Engine
	Report   func(uplink.Event)
	// Observe, when set, receives every lookup the guard answers or
	// refuses, matched or not (the --forward siem copy). It must not block.
	Observe func(siem.DNSDecision)
	Now     func() time.Time
}

Guard forwards DNS over UDP.

func (*Guard) Answer

func (g *Guard) Answer(query []byte) []byte

Answer returns the reply to one query: NXDOMAIN when the name is refused, otherwise whatever the upstream resolver said.

func (*Guard) Serve

func (g *Guard) Serve(ctx context.Context, conn net.PacketConn) error

Serve answers on conn until ctx ends.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL