Networking: Difference between revisions

From NixOS Wiki
imported>Makefu
initial batch of nixos-users
 
imported>Fadenb
Line 7: Line 7:
Sometimes the hosting provider manages ipv6 networks via a so-called ''DUID'' or ''clientid''. This snippet is required to make the network routable:
Sometimes the hosting provider manages ipv6 networks via a so-called ''DUID'' or ''clientid''. This snippet is required to make the network routable:


<pre class="nix">{ config, pkgs, ... }:
<syntaxhighlight lang="nix">
{ config, pkgs, ... }:


let
let
   # Get this from your hosting provider
   # Get this from your hosting provider
   clientid = &quot;00:11:22:33:44:55:66:77:88:99&quot;;
   clientid = "00:11:22:33:44:55:66:77:88:99";
   interface = &quot;enp2s0&quot;;
   interface = "enp2s0";
   subnet =  &quot;56&quot;;
   subnet =  "56";
   network = &quot;2001:bbb:3333:1111::/${subnet}&quot;;
   network = "2001:bbb:3333:1111::/${subnet}";
   own_ip =  &quot;2001:bbb:3333:1111::1/${subnet}&quot;;
   own_ip =  "2001:bbb:3333:1111::1/${subnet}";
in {
in {
   # ... snip ...
   # ... snip ...
Line 23: Line 24:
   networking.dhcpcd.persistent = true;
   networking.dhcpcd.persistent = true;
   networking.dhcpcd.extraConfig = ''
   networking.dhcpcd.extraConfig = ''
     clientid &quot;${clientid}&quot;
     clientid "${clientid}"
     noipv6rs
     noipv6rs
     interface ${interface}
     interface ${interface}
Line 29: Line 30:
     static ip6_address=${own_ip}
     static ip6_address=${own_ip}
   '';
   '';
   environment.etc.&quot;dhcpcd.duid&quot;.text = clientid;
   environment.etc."dhcpcd.duid".text = clientid;


}</pre>
}
</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]

Revision as of 15:54, 27 August 2017

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