4

When I want to invite my friends over the internet into my LAN world in Minecraft, I need to set my router to forward the port specified by Minecraft. As Mincraft picks a different port each time I open my world over LAN, I have to edit my router settings every time I want to start a multiplayer LAN session over the internet. Instead, I would like to set the router to the range of port numbers that Minecraft picks from.

What is the range of ports that Minecraft uses for LAN worlds?

So far, after four sessions, I have had ports between 49525 and 50852. I play the Java edition, if that makes any difference.


Alternatively:

The port range must be coded into the Minecraft code. What file(s) would I look at to find it?

2

2 Answers 2

2

Since minecraft 1.13 there is a command to change the port

/publish [<port>] e.g. /publish 9000 to set the port to 9000.

you can read more at minecraft wiki - command publish

1

Here is my workaround for a similar situation.

First of all, I wanted to access the server over the internet and I wanted my friends to join again over the internet (all of us were located outside the LAN).
2nd I am running a lot of other services on the LAN and it is unacceptable for me to open port, moreover a range of ports.

I came across the service called Tunnel In - which is a tunneling provider and cloud port forwarder. The freemium plan allowed me:

  1. Remotely access to my server, start Minecraft and learn about the port number
  2. Create a secure tunnel and expose the Minecraft server through firewall without port forwarding and without compromising the security of LAN

Here is a nice post on how to allow Minecraft through firewall.

You must log in to answer this question.