AdguardTeam/AdGuardHome · error

setting static ip: %w

Error message

setting static ip: %w

What it means

While enabling DHCP on an interface that does not currently have a static IP, AdGuard Home attempted to set a static IP via IfaceSetStaticIP and it failed; returned as HTTP 500 wrapped as 'setting static ip'.

Source

Thrown at internal/dhcpd/http_unix.go:212

			log.Info("error while checking static ip: %s; "+
				"assuming machine has static ip and going on", err)
			hasStaticIP = true
		} else if errors.Is(err, aghnet.ErrNoStaticIPInfo) {
			// Couldn't obtain a definitive answer.  Assume static IP an go on.
			log.Info("can't check for static ip; " +
				"assuming machine has static ip and going on")
			hasStaticIP = true
		} else {
			err = fmt.Errorf("checking static ip: %w", err)

			return http.StatusInternalServerError, err
		}
	}

	if !hasStaticIP {
		err = aghnet.IfaceSetStaticIP(ctx, s.conf.Logger, cmdCons, ifaceName)
		if err != nil {
			err = fmt.Errorf("setting static ip: %w", err)

			return http.StatusInternalServerError, err
		}
	}

	err = s.Start(ctx)
	if err != nil {
		return http.StatusBadRequest, fmt.Errorf("starting dhcp server: %w", err)
	}

	return 0, nil
}

type dhcpServerConfigJSON struct {
	V4            *v4ServerConfJSON `json:"v4"`
	V6            *v6ServerConfJSON `json:"v6"`
	InterfaceName string            `json:"interface_name"`
	Enabled       aghalg.NullBool   `json:"enabled"`

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Run the service with sufficient privileges (root or CAP_NET_ADMIN)
  2. Set a static IP on the interface manually beforehand, so the code skips this step
  3. Use an environment where the supported network configuration tools exist
Defensive patterns

Strategy: validation

Validate before calling

// set static IP yourself beforehand so IfaceSetStaticIP is skipped
// e.g. configure via netplan/NM, then verify:
// ip -4 addr show <iface> | grep -q 'dynamic' || echo static

Try / catch

if err := enableDHCP(...); err != nil && strings.Contains(err.Error(), "setting static ip") { /* retry with elevated privileges or pre-configure statically */ }

Prevention

When it happens

Trigger: Calling handleDHCPSetConfig to enable DHCP when hasStaticIP is false and the command-based static IP configuration (network manager / ip commands) errors — insufficient privileges, unsupported network manager, or missing tooling.

Common situations: Running the binary without root/CAP_NET_ADMIN; distros with unsupported network managers; containers where host network modification is blocked.

Related errors


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