summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2014-12-17 17:54:06 -0800
committerWilliam A. Kennington III <william@wkennington.com>2014-12-17 17:56:29 -0800
commit1036c66d43314af2b0449fed55b9e2a62a1573f9 (patch)
treeac2474fb8fc91210f638816a031e6eac64dfc677 /nixos
parentc812e45292e90d5138659574ad9c403c02718332 (diff)
downloadnixlib-1036c66d43314af2b0449fed55b9e2a62a1573f9.tar
nixlib-1036c66d43314af2b0449fed55b9e2a62a1573f9.tar.gz
nixlib-1036c66d43314af2b0449fed55b9e2a62a1573f9.tar.bz2
nixlib-1036c66d43314af2b0449fed55b9e2a62a1573f9.tar.lz
nixlib-1036c66d43314af2b0449fed55b9e2a62a1573f9.tar.xz
nixlib-1036c66d43314af2b0449fed55b9e2a62a1573f9.tar.zst
nixlib-1036c66d43314af2b0449fed55b9e2a62a1573f9.zip
nixos/network-interfaces: Add ipv6 gateway support
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/tasks/network-interfaces-scripted.nix6
-rw-r--r--nixos/modules/tasks/network-interfaces-systemd.nix2
-rw-r--r--nixos/modules/tasks/network-interfaces.nix9
3 files changed, 17 insertions, 0 deletions
diff --git a/nixos/modules/tasks/network-interfaces-scripted.nix b/nixos/modules/tasks/network-interfaces-scripted.nix
index 310527667d7a..9d61a4b05301 100644
--- a/nixos/modules/tasks/network-interfaces-scripted.nix
+++ b/nixos/modules/tasks/network-interfaces-scripted.nix
@@ -85,6 +85,12 @@ in
                     optionalString (cfg.defaultGatewayWindowSize != null)
                       "window ${cfg.defaultGatewayWindowSize}"} || true
                 ''}
+                ${optionalString (cfg.defaultGateway6 != null && cfg.defaultGateway6 != "") ''
+                  # FIXME: get rid of "|| true" (necessary to make it idempotent).
+                  ip -6 route add ::/0 via "${cfg.defaultGateway6}" ${
+                    optionalString (cfg.defaultGatewayWindowSize != null)
+                      "window ${cfg.defaultGatewayWindowSize}"} || true
+                ''}
               '';
           };
 
diff --git a/nixos/modules/tasks/network-interfaces-systemd.nix b/nixos/modules/tasks/network-interfaces-systemd.nix
index 10185c7709b5..70158fc7252b 100644
--- a/nixos/modules/tasks/network-interfaces-systemd.nix
+++ b/nixos/modules/tasks/network-interfaces-systemd.nix
@@ -51,6 +51,8 @@ in
           DHCP = override (dhcpStr cfg.useDHCP);
         } // optionalAttrs (cfg.defaultGateway != null) {
           gateway = override [ cfg.defaultGateway ];
+        } // optionalAttrs (cfg.defaultGateway6 != null) {
+          gateway = override [ cfg.defaultGateway6 ];
         } // optionalAttrs (domains != [ ]) {
           domains = override domains;
         };
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index 9c6c71a1dbb0..807a56a32d2c 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -256,6 +256,15 @@ in
       '';
     };
 
+    networking.defaultGateway6 = mkOption {
+      default = null;
+      example = "2001:4d0:1e04:895::1";
+      type = types.nullOr types.str;
+      description = ''
+        The default ipv6 gateway.  It can be left empty if it is auto-detected through DHCP.
+      '';
+    };
+
     networking.defaultGatewayWindowSize = mkOption {
       default = null;
       example = 524288;