blob: 59646f117b71630de5c823769f29792f1039abca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
{ config, lib, ... }: {
networking = let
forward_ports = [
25565
25566
];
forward_protocols = [ "tcp" "udp" ];
internal_ip = "100.64.0.2";
internal_interface = "tailscale0";
external_interface = "eno1";
in {
firewall = {
enable = true;
allowedUDPPorts = forward_ports;
allowedTCPPorts = forward_ports;
};
nat = {
enable = true;
internalInterfaces = [ internal_interface ];
externalInterface = external_interface;
forwardPorts = builtins.concatLists (
lib.lists.forEach forward_protocols (protocol:
builtins.concatMap (port: [
{
destination = "${internal_ip}:${toString port}";
proto = protocol;
sourcePort = port;
}
]) forward_ports
)
);
};
nftables = {
enable = true;
flushRuleset = true;
tables.nixos-nat = {
family = "ip";
content = ''
chain post {
masquerade
}
'';
};
};
};
}
|