iplimit

package module
v0.0.0-...-f92ab3b Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: MIT Imports: 8 Imported by: 0

README

iplimit

Name

iplimit - limits the number of IP addresses returned in A and AAAA DNS records.

Description

The iplimit plugin is a CoreDNS middleware that restricts the number of IP addresses returned in DNS responses for A (IPv4) and AAAA (IPv6) record queries. This is useful for load balancing scenarios and reducing DNS response sizes.

When a DNS query returns multiple A or AAAA records, iplimit will trim the response to contain only the specified maximum number of IP addresses. The plugin operates as a response modifier, intercepting DNS responses from upstream plugins before they reach the client.

Syntax

iplimit MAX_IPS
  • MAX_IPS is a required integer specifying the maximum number of IP addresses to return in A and AAAA records. Must be a positive integer (1 or greater).

Examples

Basic Usage

Limit A and AAAA records to a max 5 IP addresses:

.:53 {
	loadbalance round_robin
	iplimit 5
	forward . 1.1.1.1
}

How It Works

The iplimit plugin works as a response modifier in the CoreDNS plugin chain:

  1. It intercepts DNS queries and passes them to the next plugin in the chain
  2. When a response comes back, it examines the answer section
  3. For each A or AAAA record type, it limits the number of records to the configured maximum
  4. The modified response is then returned to the client

The plugin preserves all other record types (CNAME, MX, TXT, etc.) and only affects A and AAAA records.

License

This plugin is released under the MIT License. See the LICENSE file for details.

Author

Fabian Topfstedt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModResponseWriter

func ModResponseWriter(w dns.ResponseWriter, mods ...ResponseModifier) dns.ResponseWriter

Types

type Plugin

type Plugin struct {
	IPLimit int
	Next    plugin.Handler
	// contains filtered or unexported fields
}

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) ServeDNS

func (p *Plugin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

type ResponseModifier

type ResponseModifier func(*dns.Msg) error

func NewIPLimitResponseModifier

func NewIPLimitResponseModifier(ipLimit int) ResponseModifier

Jump to

Keyboard shortcuts

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