DNS Record to Redirect Different Ports to Different Hosts

2k Views Asked by At

I have a subdomain that I want to use for 2 things at once:

  • When accessed through web ports, redirect to Server 1 to show a web page,
  • When that address is used for windows remote desktop, redirect to Server 2 for remote desktop.

Is it possible to split traffic with DNS record based on the port of incoming request?

I read a bit but I couldn't figure out if SRV records would do the job, or if that would be a backward compatible method.

Thank you to anyone who gives some ideas.

Cheers!

1

There are 1 best solutions below

3
Matt Clark On

This is outside of the scope of DNS, as it's role is simply Domain Name Resolution, and ports do not exist in the DNS world.

This seems like an idea use-case for something like haproxy however, but you will still need one of the servers to route all of the traffic for another unless you use two different host names.

With HAProxy, packet flow would be the following:

User A (Web)

  • DNS Lookup of example.com -> 1.1.1.2
  • Establish TCP connection to 1.1.1.2 on port 80 (haproxy)
  • HAProxy forwards this connection to real webservice on 1.1.1.6

User B (RDP)

  • DNS Lookup of example.com -> 1.1.1.2
  • Establish TCP connection to 1.1.1.2 on port 5900 (haproxy)
  • HAProxy forwards this connection to real RDP service on 1.1.1.7