🔧 socrates: port forward for minecraft

This commit is contained in:
2022-10-10 21:54:45 -04:00
parent d4df0f75b5
commit 84244a77d9
4 changed files with 34 additions and 18 deletions

View File

@ -8,6 +8,7 @@
# see here for more info: https://minecraft.gamepedia.com/Server.properties#server.properties
serverProperties = {
server-port = 25565;
enable-query = true;
gamemode = "survival";
motd = "Vanilla Survival";
max-players = 20;

View File

@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
let
dest_ip = "100.111.208.75";
in
{
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
networking.firewall.allowedTCPPorts = [ 25565 ];
networking.firewall.extraCommands = ''
IPTABLES=${pkgs.iptables}/bin/iptables
"$IPTABLES" -t nat -A PREROUTING -p tcp --dport 25565 -j DNAT --to-destination ${dest_ip}:25565
"$IPTABLES" -t nat -A POSTROUTING -j MASQUERADE
'';
}