AdguardTeam/AdGuardHome · error

bad dhcpv6 configuration: %w

Error message

bad dhcpv6 configuration: %w

What it means

Raised inside createServers when the DHCPv6 portion of the submitted configuration fails validation in handleDHCPSetConfigV6. This covers bad IPv6 addresses in the range, invalid RA settings, or malformed string representations of IPv6 prefixes. The wrapped error identifies the exact field.

Source

Thrown at internal/dhcpd/http_unix.go:306

	v6Conf.Logger = s.conf.Logger.With("ip_version", "6")
	v6Conf.notify = s.onNotify

	srv6, err = v6Create(v6Conf)

	return srv6, enabled, err
}

// createServers returns DHCPv4 and DHCPv6 servers created from the provided
// configuration conf.
func (s *server) createServers(conf *dhcpServerConfigJSON) (srv4, srv6 DHCPServer, err error) {
	srv4, v4Enabled, err := s.handleDHCPSetConfigV4(conf)
	if err != nil {
		return nil, nil, fmt.Errorf("bad dhcpv4 configuration: %w", err)
	}

	srv6, v6Enabled, err := s.handleDHCPSetConfigV6(conf)
	if err != nil {
		return nil, nil, fmt.Errorf("bad dhcpv6 configuration: %w", err)
	}

	if conf.Enabled == aghalg.NBTrue && !v4Enabled && !v6Enabled {
		return nil, nil, fmt.Errorf("dhcpv4 or dhcpv6 configuration must be complete")
	}

	return srv4, srv6, nil
}

// handleDHCPSetConfig is the handler for the POST /control/dhcp/set_config
// HTTP API.
func (s *server) handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	l := s.conf.Logger

	conf := &dhcpServerConfigJSON{}
	conf.Enabled = aghalg.BoolToNullBool(s.conf.Enabled)
	conf.InterfaceName = s.conf.InterfaceName

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Verify range_start and range_end are valid IPv6 literals and start < end (use net.ParseIP to test)
  2. Ensure only the low 64 bits vary if using a /64 prefix, matching the server's expectations
  3. Fix any typos in the v6 gateway/router advertisement fields and re-submit the config
  4. If you do not need DHCPv6, disable the v6 block rather than leaving half-valid data

Example fix

// before
{"v6":{"range_start":"fd00::1","range_end":"fd00::0",...}}
// -> 400 bad dhcpv6 configuration: ...

// after
{"v6":{"range_start":"fd00::1","range_end":"fd00::ff",...}}
Defensive patterns

Strategy: validation

Validate before calling

func validV6Range(start, end string) bool {
	s := net.ParseIP(start); e := net.ParseIP(end)
	if s == nil || e == nil || s.To4() != nil || e.To4() != nil { return false }
	return bytes.Compare(s.To16(), e.To16()) < 0
}

Try / catch

if err := setDHCPConfig(cfg); err != nil {
    if strings.HasPrefix(err.Error(), "bad dhcpv6 configuration") { /* inspect cfg.V6 fields */ }
}

Prevention

When it happens

Trigger: POSTing dhcp/set_config with an invalid v6 block: range_start/range_end that are not a valid IPv6 pair, an invalid prefix length, or unparseable IPv6 literals (e.g. missing hex digits, wrong '::' usage).

Common situations: Confusing IPv4 and IPv6 fields in the config; using a /64 range whose start/end are reversed; mixing compressed and full IPv6 notation incorrectly; enabling DHCPv6 on a host without IPv6 support while also submitting malformed v6 data.

Related errors


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