nixos/networking/nat: add option for protocol
This commit adds an option to allow udp port forwarding (see #24894).
This commit is contained in:
parent
e84c717df6
commit
4f277bd920
@ -48,7 +48,7 @@ let
|
|||||||
# NAT from external ports to internal ports.
|
# NAT from external ports to internal ports.
|
||||||
${concatMapStrings (fwd: ''
|
${concatMapStrings (fwd: ''
|
||||||
iptables -w -t nat -A nixos-nat-pre \
|
iptables -w -t nat -A nixos-nat-pre \
|
||||||
-i ${cfg.externalInterface} -p tcp \
|
-i ${cfg.externalInterface} -p ${fwd.proto} \
|
||||||
--dport ${builtins.toString fwd.sourcePort} \
|
--dport ${builtins.toString fwd.sourcePort} \
|
||||||
-j DNAT --to-destination ${fwd.destination}
|
-j DNAT --to-destination ${fwd.destination}
|
||||||
'') cfg.forwardPorts}
|
'') cfg.forwardPorts}
|
||||||
@ -133,12 +133,19 @@ in
|
|||||||
destination = mkOption {
|
destination = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
example = "10.0.0.1:80";
|
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 = [];
|
default = [];
|
||||||
example = [ { sourcePort = 8080; destination = "10.0.0.1:80"; } ];
|
example = [ { sourcePort = 8080; destination = "10.0.0.1:80"; proto = "tcp"; } ];
|
||||||
description =
|
description =
|
||||||
''
|
''
|
||||||
List of forwarded ports from the external interface to
|
List of forwarded ports from the external interface to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user