Networking: Difference between revisions

From NixOS Wiki
imported>Fadenb
imported>Averelld
mNo edit summary
Line 35: Line 35:
</syntaxhighlight>
</syntaxhighlight>
Source: [https://gist.github.com/gleber/9429ea43e6beb114250c3529b5c9d522 gleber gist for online.net IPv6 config in NixOS]
Source: [https://gist.github.com/gleber/9429ea43e6beb114250c3529b5c9d522 gleber gist for online.net IPv6 config in NixOS]
Note: Recent versions of dhcpcd move the duid file to /var/db/dcpcd/duid. For that to work, you have to replace the above environment.etc line with something like:
<syntaxhighlight lang="nix">
systemd.services.dhcpcd.preStart = ''
  cp ${pkgs.writeText "duid" "<ID>"} /var/db/dhcpcd/duid
'';
</syntaxhighlight>

Revision as of 17:36, 9 September 2018

This site provides snippets for configuring your network just right for the use case you are looking for. All configuration is for configuration.nix

IPv6

Prefix delegation with fixed DUID

Sometimes the hosting provider manages ipv6 networks via a so-called DUID or clientid. This snippet is required to make the network routable:

{ config, pkgs, ... }:

let
  # Get this from your hosting provider
  clientid = "00:11:22:33:44:55:66:77:88:99";
  interface = "enp2s0";
  subnet =  "56";
  network = "2001:bbb:3333:1111::/${subnet}";
  own_ip =  "2001:bbb:3333:1111::1/${subnet}";
in {
  # ... snip ...

  networking.enableIPv6 = true;
  networking.useDHCP = true;
  networking.dhcpcd.persistent = true;
  networking.dhcpcd.extraConfig = ''
    clientid "${clientid}"
    noipv6rs
    interface ${interface}
    ia_pd 1/${network} ${interface}
    static ip6_address=${own_ip}
  '';
  environment.etc."dhcpcd.duid".text = clientid;

}

Source: gleber gist for online.net IPv6 config in NixOS

Note: Recent versions of dhcpcd move the duid file to /var/db/dcpcd/duid. For that to work, you have to replace the above environment.etc line with something like:

systemd.services.dhcpcd.preStart = ''
  cp ${pkgs.writeText "duid" "<ID>"} /var/db/dhcpcd/duid
'';