A
Admincraft•3d ago
grg

How do I port forward local Minecraft server through a separate server that I have?

I don't even know how to google what I'm trying to do, but here is the gist of it: I have a local server running on my computer 127.0.0.1:25565 and I have a separate server that I use for WireGuard and which I have access too How do I use that server so that other people can join the Minecraft server through it? ATM I'm using playit.gg and it works good... most of the time, by which I mean that it drops connections for people randomly (I also have bluemap working and I'd like to know if I can use that too)
17 Replies
Upioti
Upioti•3d ago
Wheres that other server from?
grg
grgOP•3d ago
It's from a hosting provider The server is situated in france
Upioti
Upioti•3d ago
Yeah what hosting provider
grg
grgOP•3d ago
oh, it's aeza.net
Upioti
Upioti•3d ago
Playit could still give a better experience overall
grg
grgOP•3d ago
What do you mean? Because it's easier to set up?
Upioti
Upioti•3d ago
no because they have way better machines with better uplinks located across the world anycasted And aeza's tcp mitigation is a bit weird so it may also kick players To forward a port from your WireGuard VPN server's public IP to a client (VPN peer), you'll need to configure iptables or firewalld on the VPN server to perform port forwarding (NAT rules). --- Steps to Forward a Port from the VPN Server to a WireGuard Client 1. Enable IP Forwarding on the VPN Server Ensure that the VPN server allows forwarding traffic between interfaces. Run:
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
--- 2. Set Up an iptables Rule for Port Forwarding Assume: - The VPN server's public IP is 1.2.3.4 - The WireGuard interface is wg0 - The client has the internal VPN IP 10.0.0.2 - You want to forward port 12345 (TCP) from the VPN server to the client Run:
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 12345 -j DNAT --to-destination 10.0.0.2:12345
sudo iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 12345 -j MASQUERADE
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 12345 -j DNAT --to-destination 10.0.0.2:12345
sudo iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 12345 -j MASQUERADE
For UDP, change -p tcp to -p udp. --- 3. Allow Forwarding in iptables
sudo iptables -A FORWARD -i eth0 -o wg0 -p tcp --dport 12345 -d 10.0.0.2 -j ACCEPT
sudo iptables -A FORWARD -i wg0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o wg0 -p tcp --dport 12345 -d 10.0.0.2 -j ACCEPT
sudo iptables -A FORWARD -i wg0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
If using firewalld instead of iptables:
sudo firewall-cmd --add-forward-port=port=12345:proto=tcp:toaddr=10.0.0.2 --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --add-forward-port=port=12345:proto=tcp:toaddr=10.0.0.2 --permanent
sudo firewall-cmd --reload
--- 4. Persist iptables Rules To keep the rules after a reboot, save them:
sudo iptables-save | sudo tee /etc/iptables/rules.v4
sudo iptables-save | sudo tee /etc/iptables/rules.v4
To restore them on boot, add this line to /etc/rc.local or use a systemd service. --- 5. Configure the Client (10.0.0.2) Make sure the service listening on port 12345 on the WireGuard client is properly configured to accept traffic from 10.0.0.1 (server). --- Testing the Port Forwarding From any external machine, try:
nc -vz 1.2.3.4 12345
nc -vz 1.2.3.4 12345
If it's UDP:
nc -u 1.2.3.4 12345
nc -u 1.2.3.4 12345
On the client (10.0.0.2), you can run:
nc -lvp 12345
nc -lvp 12345
or
nc -u -lvp 12345 # For UDP
nc -u -lvp 12345 # For UDP
If it works, external connections to 1.2.3.4:12345 will be forwarded to 10.0.0.2:12345 over WireGuard. --- Bonus: Debugging If it doesn't work, check: - WireGuard status (wg show) - iptables rules (sudo iptables -t nat -L -v -n) - Firewall logs (sudo dmesg | grep DROP) Let me know if you need adjustments for your setup! 🚀
grg
grgOP•3d ago
Alright, I'm gonna try this tomorrow, now is a bit late, thanks Welp, didn't work I checked and I have the connection
Snow Kit
Snow Kit•2d ago
it’s almost like they just pasted a response from chatgpt into discord
Snow Kit
Snow Kit•2d ago
honestly, just run velocity https://papermc.io/software/velocity on the vps (for bluemap, you might also need to run nginx, haproxy, traefik or caddy)
PaperMC
Velocity
Velocity is the modern, high-performance Minecraft server proxy. Designed with performance and stability in mind, it’s a full alternative to Waterfall with its own plugin ecosystem.
grg
grgOP•2d ago
Yeah... I figured, but still gave it a shot Is it just a proxy that I install on the VPS?
Snow Kit
Snow Kit•2d ago
yeah, it’s a proxy designed for minecraft will allow multiple servers on the same port too
grg
grgOP•2d ago
I see, that seems to be exactly what I need then, it seems to even support multiple ports I'll check it out later, thank you!
Upioti
Upioti•2d ago
He said he doesnt want a proxy because he can't port foward bruh
Snow Kit
Snow Kit•2d ago
re-read that message I sent
Upioti
Upioti•2d ago
You right, he never said he couldn't port foward I just assumed based on what he explained
Snow Kit
Snow Kit•2d ago
velocity works fine over a vpn no need for port forwarding

Did you find this page helpful?