Is there a way of having only a certain subdomain access a port?

Let's say I have a Minecraft server running on default port 25565. I also have domain.com which is pointed to the IP of the server, because I also host a website with apache2 on it. mc.domain.com is set up as a subdomain. If I put domain.com into the Minecraft client, it will connect to the minecraft server. If I put mc.domain.com into the Minecraft client, it will also connect to the minecraft server.

Can I make it so that only mc.domain.com will connect, and that if a user enters domain.com or any other subdomain into Minecraft, it won't connect to the server?

1 Answer 1


No, you can't. The DNS name is translated to an IP address, and at the time your client connects to the server, it is connecting to an IP address + port number.

You can use another IP addresses (two IP addresses on the same server), and allow connections to only one IP address (and that's the one to which you point the mc.domain.com record). Or just live with the fact that you can also connect by the other hostname of course.

Not the answer you're looking for? Browse other questions tagged or ask your own question.