AdguardTeam/AdGuardHome · error

range is too large

Error message

range is too large

What it means

Returned by newIPRange when end-start exceeds the allowed maximum (maxRangeLen) or the difference does not fit a uint64. This prevents absurd ranges like 0.0.0.0–255.255.255.255 that would exhaust memory or make no operational sense.

Source

Thrown at internal/dhcpd/iprange.go:46

const maxRangeLen = math.MaxUint32

// newIPRange creates a new IP address range.  start must be less than end.  The
// resulting range must not be greater than maxRangeLen.
func newIPRange(start, end net.IP) (r *ipRange, err error) {
	defer func() { err = errors.Annotate(err, "invalid ip range: %w") }()

	// Make sure that both are 16 bytes long to simplify handling in
	// methods.
	start, end = start.To16(), end.To16()

	startInt := (&big.Int{}).SetBytes(start)
	endInt := (&big.Int{}).SetBytes(end)
	diff := (&big.Int{}).Sub(endInt, startInt)

	if diff.Sign() <= 0 {
		return nil, fmt.Errorf("start is greater than or equal to end")
	} else if !diff.IsUint64() || diff.Uint64() > maxRangeLen {
		return nil, fmt.Errorf("range is too large")
	}

	r = &ipRange{
		start: startInt,
		end:   endInt,
	}

	return r, nil
}

// contains returns true if r contains ip.
func (r *ipRange) contains(ip net.IP) (ok bool) {
	if r == nil {
		return false
	}

	ipInt := (&big.Int{}).SetBytes(ip.To16())

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Narrow the range to your actual subnet, typically a small slice like 192.168.1.50–192.168.1.250
  2. Confirm your subnet mask matches the range size (e.g. /24 supports at most ~253 usable addresses)
  3. For DHCPv6, keep the range within the low 64 bits of a single /64 prefix

Example fix

// before
"range_start":"0.0.0.0","range_end":"255.255.255.255"
// -> range is too large

// after
"range_start":"192.168.1.50","range_end":"192.168.1.250"
Defensive patterns

Strategy: validation

Validate before calling

func rangeSizeOK(start, end string) bool {
	s, e := net.ParseIP(start), net.ParseIP(end)
	if s == nil || e == nil { return false }
	d := big.NewInt(0).Sub(bytesToBig(e.To16()), bytesToBig(s.To16()))
	return d.IsUint64() && d.Uint64() <= maxRangeLen // 65536 in adguard's dhcpd
}

Prevention

When it happens

Trigger: Submitting a range spanning more than maxRangeLen addresses — classically range_start 0.0.0.0 with range_end 255.255.255.255, or a /8 subnet — or an IPv6 range whose low-bits difference exceeds the uint64 limit.

Common situations: Leaving range fields at their placeholder defaults; misunderstanding subnet size (a /16 gives 65k addresses but a /8 gives 16M); trying to 'cover everything' with 0.0.0.0–255.255.255.255.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/08a25758a3dca40c. Report an issue: GitHub.