0

I have been searching a solution to this for some time and it seems not possible, but maybe I am missing something. I have research DNS, reverse proxys, 1to1 nat...

I have a bunch of local systems at home with zeroconf running. Example:

  • raspberry.local
  • laptop.local
  • pc.local

They talk to each other without problem. I have a router that connects my systems to internet with only one IP.

I have a domain bought, e.g: mydomain.com.

Is there a way to map public subdomains to local domains? Redirecting all ports and services based on subdomain (not only web, also ssh)

Right now I am tinkering with port forwarding but this doesn't escalate.


What I have:

  • mydomain.com:3022 => raspberry.local:22
  • mydomain.com:4022 => laptop.local:22

What I want:

  • raspberry.mydomain.com:* => raspberry.local:*
  • laptop.mydomain.com:* => laptop.local:*
  • Regular port forwarding is not concerned with DNS names at all. If you have one public IP address, you can only forward a port to a single machine. – Daniel B Mar 25 '18 at 14:39
  • A similar question came up before and you may find my answer helpful. – AFH Mar 25 '18 at 15:45
  • @AFH I've read your answer a couple of times. If I understand it properly, you were trying to redirect public subdomains to diferent ports of the same internal IP? And always use port 80 to access it, right? – Susensio Mar 25 '18 at 16:56
  • Yes, always port 80 on the public host, but the redirection is to different ports on my home server, though this is transparent to the client. – AFH Mar 25 '18 at 17:15
1

Domain names are not related to ports, only IP addresses... In the "Internet" they are only related to public IP addresses specifically. There is really nothing in the DNS domain record that would allow it to point to a specific internal LAN server IP or name.

You can setup 'mydomain.com' to point to an IP of 12.13.14.15 or whatever IP you wish, and if you have setup DNS records for various subdomains like 'raspberry.mydomain.com' you can point that to the same or a different IP address, but your router or server must port forward those IP addresses to the correct internal host.

Do not confuse this with a web server's mapping, where it gets a request for 'http://blog.mydomain.com' and knows that maps to 'mydomain.com/web/blog/index.html' or to 'webserver.local/web/pages/blog/index.html' because it is explicitly implied in the server to redirect there, which is something completely different. The DNS record doesn't do that, but the http request contains the domain name url being requested.

To be honest, in a residential or small business environment, your first solution of unique ports for various services to different machines if often the most feasible. In medium to larger businesses, it is often common to have multiple public IP addresses for mapping things to different hosts.

  • So, If I understand correctly, there is no way of redirecting, say, a ssh packet when it reaches my router to an specific internal machine because there is no information in the packet about the original hostname, only the IP resolved by some DNS, right? – Susensio Mar 25 '18 at 15:05
  • @Susensio I don't believe a normal SSH request includes the original requested DNS name (like http requests include the url), so that isn't possible because the request is just to an IP address on a specific port (22), the router has no way to determine if it is for raspberry.local or laptop.local because that original information entered by the requester is not presented to it, only the IP address and port. And if it was (as some other types of requests may include the original DNS name) it would take a specialized enterprise grade router or proxy server to handle that translation. – acejavelin Mar 25 '18 at 15:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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