Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect DNS to different ports

TL;DR:

DNS resolution of a domain(s) must map to IP:port(s), instead of just IP.

Example,

sub1.example.com 🡲 1.2.3.4:567
sub2.example.com 🡲 1.2.3.4:678

I CAN modify DNS records.


I own the domain "Arboristal.com". I also own all sub domains privately on arboristal.com. Such as lg.arboristal or ft.arboristal.com.

Under my DNS settings, Arboristal.com is set to go to our web host who is currently hosting our website.

I have three servers running at my house all running under one public IP address. (71.82.237.27)

I also have three subdomains of Arboristal.com pointing towards my IP address.

Each of the three servers run on their own ports (25565, 25566, 25567)

I want for each subdomain to point to each open port on my IP Address.

Unfortunately when you try to connect to one of these servers using one of the subdomains it only connects to the server that you type the port for.

My situation:

Three servers, each running on a different port. (All portforwarded and working as servers)

  • Minecraft server one (25565)

  • Minecraft server two (25566)

  • Minecraft server three (25567)

I have three subdomains running on my DNS provider (webs.com)

  • mc.arboristal.com

  • tekkit.arboristal.com

  • pvp.artboristal.com

When you use Minecraft to connect to one of these it does automatically through port 25565, meaning that no matter what URL you attempt to connect to it always goes to my IP with the port 25565. Connecting you to Minecraft server one. You CAN type in the port manually, but I would rather keep this as good looking and professional as possible.

So, now that you know my situation, is there any possible way I can make mc.arboristal.com, tekkit.arboristal.com, and pvp.arboristal.com all go to my IP address under different ports without having to specify each port in the provided URL to connect to on the users end?

I can add MX, A (Using this one to connect to the server), CNAME, and TXT records to DNS settings

I can also add Name Servers to DNS settings if I need to use a third party as my DNS provider. (Am willing to do if necessary)

I also have full access to my router at 192.168.0.1 if anything needs to be configured there.

I have only just learned how the internet really functions in the last week so I am unsure if anything here is actually possible. I also may not have the right information about how the internet actually works. Please forgive me for any false information that I may assume about the internet.

like image 565
Swordstoo Avatar asked Sep 25 '13 21:09

Swordstoo


People also ask

Can DNS redirect to different port?

In order to redirect DNS to different ports, a service record (SRV) plays an important role. An SRV record is a type of DNS record that contains information about the location of a particular service. Additionally, the SRV record contains the server address to connect to that service.

How do I redirect to a different port?

Redirect MethodUse a 302 Redirect (temporary/found) to redirect a browser hitting this URL/Virtual Host to the new URL. This method changes the URL in the browser so the browser actually shows the 8080 and 8090 ports.

How do I redirect a DNS?

If you have multiple domains, select the domain that you want to create the redirect for. Click DNS settings on the Advanced settings tile. If you want to keep displaying the domain you're redirecting from as the URL in the address bar of your browser, then check the box. Click Save to create the redirect.

How do I redirect an IP to a port?

Under Hostname Type, select Port 80 Redirect. Enter your current Public IP Address in the IP Address field. Enter the Port number you would like the HTTP requests sent to. Scroll down and click the Add Hostname button when finished to save your configuration.


1 Answers

You can use SRV records:

_service._proto.name. TTL class SRV priority weight port target. 

Service: the symbolic name of the desired service.

Proto: the transport protocol of the desired service; this is usually either TCP or UDP.

Name: the domain name for which this record is valid, ending in a dot.

TTL: standard DNS time to live field.

Class: standard DNS class field (this is always IN).

Priority: the priority of the target host, lower value means more preferred.

Weight: A relative weight for records with the same priority.

Port: the TCP or UDP port on which the service is to be found.

Target: the canonical hostname of the machine providing the service, ending in a dot.

Example:

_sip._tcp.example.com. 86400 IN SRV 0 5 5060 sipserver.example.com. 

So what I think you're looking for is to add something like this to your DNS hosts file:

_minecraft._tcp.arboristal.com. 86400 IN SRV 10 40 25565 mc.arboristal.com. _minecraft._tcp.arboristal.com. 86400 IN SRV 10 30 25566 tekkit.arboristal.com. _minecraft._tcp.arboristal.com. 86400 IN SRV 10 30 25567 pvp.arboristal.com. 

(Minecraft supports SRV records, as of 1.3.1, with the service name minecraft)

On a side note, I highly recommend you go with a hosting company rather than hosting the servers yourself. It's just asking for trouble with your home connection (DDoS and Bandwidth/Connection Speed), but it's up to you.

like image 166
Winter Avatar answered Sep 21 '22 00:09

Winter