Send DNS traffic for a domain to different IP addresses based on port
I have been experimenting with my home lab for the past few years. I have 3 boxes running a few different services. One of them is configured as a DNS server. I have a local domain name of exampledomain.net that points to server 1. However, I also have different services running on servers 2 and 3 that I would like to be able to access through exampledomain.net. Is there any way I can tell my DNS server to point all exampledomain.net traffic on port x to server 1, port y to server 2, and port z to server 3? In researching this, I came across SRV records, however I am not too familiar with them, and am not sure if they will be helpful in this instance. Thanks!
Solution 1:
Is there any way I can tell my DNS server to point all exampledomain.net traffic on port x to server 1, port y to server 2, and port z to server 3?
No. DNS is not used to resolve domain:port pairs, only the domain itself.
If your servers are all behind NAT, just use...NAT. That is, if your domain points to a "public" IP address but you're using port forwarding to reach your servers with "private" addresses, then you can actually change those port forwarding rules to point to server 2 and so on.
(If those services aren't all HTTP based, then you might not need to do anything special, the clients for each service will already use their own default ports – e.g. ssh will use its own and ftp will use its own.)
In researching this, I came across SRV records, however I am not too familiar with them, and am not sure if they will be helpful in this instance.
SRV records are used for a different purpose – they're for mapping domain → address:port
, noting that only the domain is still the input and not domain:port.
They're also not used by regular HTTP clients. Only very few services (XMPP, Minecraft, Kerberos) actually use SRV.