summary refs log tree commit diff
path: root/nixos/modules/services/networking/nat.nix
diff options
context:
space:
mode:
authorPhil <phil@grmr.de>2017-08-04 16:25:28 +0200
committerRobin Gloster <mail@glob.in>2017-08-04 17:03:05 +0200
commit4f277bd92056d74c5608be0e508283b09ec49cce (patch)
tree16fb679d1a606b90037b17d74ac12dcf5a561795 /nixos/modules/services/networking/nat.nix
parente84c717df69f21d3924a4716bb8c50fe2693f08a (diff)
downloadnixpkgs-4f277bd92056d74c5608be0e508283b09ec49cce.tar
nixpkgs-4f277bd92056d74c5608be0e508283b09ec49cce.tar.gz
nixpkgs-4f277bd92056d74c5608be0e508283b09ec49cce.tar.bz2
nixpkgs-4f277bd92056d74c5608be0e508283b09ec49cce.tar.lz
nixpkgs-4f277bd92056d74c5608be0e508283b09ec49cce.tar.xz
nixpkgs-4f277bd92056d74c5608be0e508283b09ec49cce.tar.zst
nixpkgs-4f277bd92056d74c5608be0e508283b09ec49cce.zip
nixos/networking/nat: add option for protocol
This commit adds an option to allow udp port forwarding (see #24894).
Diffstat (limited to 'nixos/modules/services/networking/nat.nix')
-rw-r--r--nixos/modules/services/networking/nat.nix13
1 files changed, 10 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/nat.nix b/nixos/modules/services/networking/nat.nix
index 41e0a8c8474..366bb2ed7a8 100644
--- a/nixos/modules/services/networking/nat.nix
+++ b/nixos/modules/services/networking/nat.nix
@@ -48,7 +48,7 @@ let
     # NAT from external ports to internal ports.
     ${concatMapStrings (fwd: ''
       iptables -w -t nat -A nixos-nat-pre \
-        -i ${cfg.externalInterface} -p tcp \
+        -i ${cfg.externalInterface} -p ${fwd.proto} \
         --dport ${builtins.toString fwd.sourcePort} \
         -j DNAT --to-destination ${fwd.destination}
     '') cfg.forwardPorts}
@@ -133,12 +133,19 @@ in
           destination = mkOption {
             type = types.str;
             example = "10.0.0.1:80";
-            description = "Forward tcp connection to destination ip:port";
+            description = "Forward connection to destination ip:port";
+          };
+
+          proto = mkOption {
+            type = types.str;
+            default = "tcp";
+            example = "udp";
+            description = "Protocol of forwarded connection";
           };
         };
       });
       default = [];
-      example = [ { sourcePort = 8080; destination = "10.0.0.1:80"; } ];
+      example = [ { sourcePort = 8080; destination = "10.0.0.1:80"; proto = "tcp"; } ];
       description =
         ''
           List of forwarded ports from the external interface to