🚑 minecraft: fix nat forwarding

This commit is contained in:
James Walker 2024-07-12 15:09:14 -04:00
parent fe3911ab2c
commit fed866990c
Signed by: walkah
SSH Key Fingerprint: SHA256:f7Gn4jO4BFHZxWfKTTzEAfWz+cLW51IyGFl9MjDyZGI

View File

@ -1,14 +1,32 @@
{ pkgs, ... }: _:
let let
dest_ip = "100.111.208.75"; dest_ip = "100.111.208.75";
dest_port = 25565;
in in
{ {
boot.kernel.sysctl."net.ipv4.ip_forward" = 1; networking = {
networking.firewall.allowedTCPPorts = [ 25565 ]; firewall = {
enable = true;
allowedTCPPorts = [ dest_port ];
};
nat = {
enable = true;
internalInterfaces = [ "tailscale0" ];
externalInterface = "eth0";
forwardPorts = [
{
sourcePort = dest_port;
proto = "tcp";
destination = "${dest_ip}:${toString dest_port}";
}
];
};
};
networking.firewall.extraCommands = '' services = {
IPTABLES=${pkgs.iptables}/bin/iptables tailscale = {
"$IPTABLES" -t nat -A PREROUTING -p tcp --dport 25565 -j DNAT --to-destination ${dest_ip}:25565 useRoutingFeatures = "server";
"$IPTABLES" -t nat -A POSTROUTING -o tailscale0 -j MASQUERADE extraUpFlags = [ "--stateful-filtering=false" ];
''; };
};
} }