git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/networking/nat: add option for protocol

This commit adds an option to allow udp port forwarding (see #24894).

commit4f277bd92056d74c5608be0e508283b09ec49cce authorPhil <phil@grmr.de> dateFri 4 Aug 2017, 16:25 (9 years ago) parente84c717
1 file changed+10−3
nixos/modules/services/networking/nat.nix+10−3
nixos/modules/services/networking/nat.nix+10−3
@@ -48,7 +48,7 @@ let
4848 # NAT from external ports to internal ports.
4949 ${concatMapStrings (fwd: ''
5050 iptables -w -t nat -A nixos-nat-pre \
51− -i ${cfg.externalInterface} -p tcp \
51+ -i ${cfg.externalInterface} -p ${fwd.proto} \
5252 --dport ${builtins.toString fwd.sourcePort} \
5353 -j DNAT --to-destination ${fwd.destination}
5454 '') cfg.forwardPorts}
@@ -133,12 +133,19 @@ in
133133 destination = mkOption {
134134 type = types.str;
135135 example = "10.0.0.1:80";
136− description = "Forward tcp connection to destination ip:port";
136+ description = "Forward connection to destination ip:port";
137+ };
138+
139+ proto = mkOption {
140+ type = types.str;
141+ default = "tcp";
142+ example = "udp";
143+ description = "Protocol of forwarded connection";
137144 };
138145 };
139146 });
140147 default = [];
141− example = [ { sourcePort = 8080; destination = "10.0.0.1:80"; } ];
148+ example = [ { sourcePort = 8080; destination = "10.0.0.1:80"; proto = "tcp"; } ];
142149 description =
143150 ''
144151 List of forwarded ports from the external interface to