summary refs log tree commit diff
path: root/nixos/modules/services/networking
diff options
context:
space:
mode:
authorevujumenuk <evujumenuk@mailinator.com>2017-08-08 01:45:19 +0200
committerGitHub <noreply@github.com>2017-08-08 01:45:19 +0200
commiteaab02b94f729c8e230c6b7f52ad83091f6fc0d6 (patch)
tree129caf95c2e12ffdb75c7ce9b3f749fa85ad7d11 /nixos/modules/services/networking
parent6070d91e93c29dc53a2d71c7a9505255f1a48459 (diff)
downloadnixlib-eaab02b94f729c8e230c6b7f52ad83091f6fc0d6.tar
nixlib-eaab02b94f729c8e230c6b7f52ad83091f6fc0d6.tar.gz
nixlib-eaab02b94f729c8e230c6b7f52ad83091f6fc0d6.tar.bz2
nixlib-eaab02b94f729c8e230c6b7f52ad83091f6fc0d6.tar.lz
nixlib-eaab02b94f729c8e230c6b7f52ad83091f6fc0d6.tar.xz
nixlib-eaab02b94f729c8e230c6b7f52ad83091f6fc0d6.tar.zst
nixlib-eaab02b94f729c8e230c6b7f52ad83091f6fc0d6.zip
wireguard: convert "table" to an interface option
Do the right thing, and use multiple interfaces for policy routing. For example, WireGuard interfaces do not allow multiple routes for the same CIDR range.
Diffstat (limited to 'nixos/modules/services/networking')
-rw-r--r--nixos/modules/services/networking/wireguard.nix20
1 files changed, 11 insertions, 9 deletions
diff --git a/nixos/modules/services/networking/wireguard.nix b/nixos/modules/services/networking/wireguard.nix
index 5aa4f13d4529..4f54b45639f6 100644
--- a/nixos/modules/services/networking/wireguard.nix
+++ b/nixos/modules/services/networking/wireguard.nix
@@ -79,6 +79,16 @@ let
         description = "A list of commands called after shutting down the interface.";
       };
 
+      table = mkOption {
+        default = "main";
+        type = types.str;
+        description = ''The kernel routing table to add this interface's
+        associated routes to. Setting this is useful for e.g. policy routing
+        ("ip rule") or virtual routing and forwarding ("ip vrf"). Both numeric
+        table IDs and table names (/etc/rt_tables) can be used. Defaults to
+        "main".'';
+      };
+
       peers = mkOption {
         default = [];
         description = "Peers linked to the interface.";
@@ -160,14 +170,6 @@ let
         interval of 25 seconds; however, most users will not need this.'';
       };
 
-      table = mkOption {
-        default = "main";
-        type = types.str;
-        description = ''The kernel routing table to add this peer's associated
-        routes to. Setting this is useful for e.g. policy routing ("ip rule")
-        or virtual routing and forwarding ("ip vrf"). Both numeric table IDs
-        and table names (/etc/rt_tables) can be used. Defaults to "main".'';
-      };
     };
 
   };
@@ -217,7 +219,7 @@ let
 
             (map (peer:
             (map (allowedIP:
-            "${ipCommand} route replace ${allowedIP} dev ${name} table ${peer.table}"
+            "${ipCommand} route replace ${allowedIP} dev ${name} table ${values.table}"
             ) peer.allowedIPs)
             ) values.peers)