NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.53k stars 13.71k forks source link

[services.ddclient] IP discovery fails with `usev4=ifv4` #336189

Open bonsairobo opened 1 month ago

bonsairobo commented 1 month ago

Describe the bug

The ddclient service will fail to discover an IPv4 address with the following error message:

Aug 20 14:27:10 nixrt ddclient[135978]: FAILED:   Unable to obtain default route information -- missing ip or ifconfig command
Aug 20 14:27:10 nixrt ddclient[135978]: WARNING:  mydomain.com: unable to determine IPv4 address with strategy usev4=ifv4
  services.ddclient = {
    enable = true;
    interval = "5min";

    # IP discovery
    usev4 = "ifv4";
    usev6 = ""; # disable IPv6 (AAAA) record
    extraConfig = ''
      ifv4=wan0
    '';

    # A record
    zone = "mydomain.com";
    domains = ["mydomain.com"];

    # Cloudflare API
    protocol = "cloudflare";
    username = "token";
    passwordFile = "${config.sops.secrets."cloudflare/api-token".path}";
  };

I believe the issue is that the systemd service path is not including pkgs.iproute2. My workaround is to add this:

  systemd.services.ddclient.path = [pkgs.iproute2];

We can see in the service derivation that this path is optional, but the condition is too restrictive.

https://github.com/NixOS/nixpkgs/blob/d2f3b99a6b7b74a6fecaac280d88ecb4b5b28c5a/nixos/modules/services/networking/ddclient.nix#L230

Steps To Reproduce

  1. Add a configuration like the one above to your NixOS configuration, replacing wan0 with an existing WAN interface.
  2. Deploy the configuration and check journalctl -u ddclient to see the failure.

Expected behavior

The service should succeed to discover and IPv4 address, like it does after I apply my workaround.

Notify maintainers

@bjornfor

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.46, NixOS, 24.11 (Vicuna), 24.11.20240818.8a33541`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"nixos-24.05"`
 - nixpkgs: `/nix/store/d9gbq853jvbccrz5g3y0irbwgc57w137-source`

Add a :+1: reaction to issues you find important.

bjornfor commented 1 week ago

@bonsairobo: Since you already found a fix, can you submit a PR?