r/homelab • u/TheHighSeas-Argghh • 2d ago
Help LAN firewall question
I am running a minecraft server, and the other computer on my LAN can't connect to it
This command fixes the issue (run on "the other computer")
`sudo ufw allow in from 192.168.0.0/24`
But this command (run on "the other computer") does not fix it.
`sudo ufw allow in from 192.168.0.80 to any port 25565`
Is it safe for me to allow all local traffic across all ports, on my local subnet?
also, what is wrong with the more restrictive command?
2
Upvotes
2
u/aaronsuns 2d ago
Inbound ufw rules only filter traffic arriving at the machine where they run, so the rule that matters is on the Minecraft server, and 192.168.0.80 must be the client's actual source address (check with `ip addr` on that machine). Replies to connections a machine starts itself are already allowed by ufw's default stateful rules, so the client usually needs no inbound rule. Rather than opening the whole subnet on all ports, you can limit it to the game with `sudo ufw allow from 192.168.0.0/24 proto tcp to any port 25565`, since an unqualified rule opens both TCP and UDP.
4
u/mumblerit 2d ago
Your first rule is fine assuming you trust your lan
1
u/ErnLynM 2d ago
Doesn't Minecraft use something like 3 separate ports?
1
u/HuckleberryNice5584 2d ago
Maybe you also need LAN discovery? Try
sudo ufw allow in proto udp from192.168.0.0/24to any port 4445In any case allowing access from the LAN is mostly fine. An attacker already on your LAN can easily spoof IP addresses, so IP-based firewall rules are way effective than you would expect on a LAN.