0

So the basic idea is stated in the question above, but let me explain.

I was thinking of hosting a Minecraft server inside a VM (using bridge mode so I can direct traffic to it via port forwarding) on my dedicated server here at home. Now I recently got asked by a friend if I could also host a server for his moderately small discord server. Naturally I agreed. My plan would be to simply open up a second VM for his server to run in and give him SSH access to it.

Now however, am am faced with the issue of Minecraft using a certain port to connect by default. I don't really want to require people to add in a port number at the end of the URL. So how can I seperaten the traffic meant for one VM from the traffic meant for the other VM if the incoming traffic for both is on the same port? Is that even possible? Can I forward the same port to two different internal ip addresses?

I was thinking maybe using mc1.mydomain.com and mc2.mydomain.com to have traffic automatically routed to different incoming ports, aka. bind ports to the domain name.

I have no idea if I am just fantasizing about something impossible. Some help would be appreciated.

Thanks in advance.

PS: I have no option to use a fixed IP address so I am limited to dynamic DNS services.

  • Only if the protocol is hostname aware and you can separate out traffic for one host or another at the application layer. See for example https://serverfault.com/q/878080/546643 – Bob Apr 19 '21 at 14:15
  • Unicast packets are destined to a single host (the "_uni_" in unicast). – Ron Maupin Apr 19 '21 at 14:38

1 Answers1

1

You can't, a single TCP port can only be forwarded to a single internal server (unless you want to load balance them, for which you would require 1) a load balancer and 2) two servers that actually run the same application, not two different ones).

Something like that can only be done with HTTP(S) using a reverse proxy, which can inspect the requested URL and send the traffic to different servers based on what was requested; this allows publishing multiple web servers through the same reverse proxy. But this is only possible because HTTP(S) explicitly supports it at the application layer. There is nothing like that at the network layer, you can only work with IP addresses and ports there.

Massimo
  • 68,714
  • 56
  • 196
  • 319