I want it to be so that, when I attempt to visit my server at 94.xx.xx.xx, it will automatically redirect me to the internal address 192.xx.xx.xx, when doing so from the local network. Can this be done with OS X DNS and if so how?

  • Have you looked into ssh -l? – perhapsmaybeharry Apr 13 '16 at 10:10
  • I didn't mention this, but it is actually for some FTP services and shares, so I imagine this couldn't help me? – Emil L. Apr 13 '16 at 11:16
  • Is the 94.xx.xx.xx address the external address on the LAN? As in, is it the same server that you are trying to reach, just by a different IP address? Finally, are you accessing it by DNS name or by numeric address? – samh Apr 13 '16 at 11:51
  • @samh the 94.xx.xx.xx is the external address, and yes, same server by different IP. And I only ever attempt access numerically with IP addresses. – Emil L. Apr 14 '16 at 13:55
  • Flagged the question as unclear! Your question is missing some preliminary research how IP-networks and DNS works and how both are related. – klanomath Apr 14 '16 at 21:33

No, it cannot be done by OS X DNS or any DNS, because you aren't interacting with DNS in your situation (according to your comment). Domain Name Service translates domain names into IP addresses and you aren't using any domain names to access the server.

If however, you set up DNS and used one name on external DNS and the same name on internal DNS - the same name could resolve to different addresses.

  • name.pretendco.com
  • name.pretendco.com

It doesn't matter if the numbers are at all similar, but you might find it easier to map things or check that the servers are correct. Setting up an internal DNS is worth the effort if you have several dozen hosts - otherwise it's easier to overload the local hosts file on the machines that need to resolve the name "internally" as opposed to externally.

(If you were using fully qualified domain names, there are ways to do this…I don't how "accepted" they are and I'm not enough of an expert to tell you all the possible side effects, but it can work.)

The issue you're having is a routing issue, from what I understand. Your public IP address is on a router that is not your server. Your server uses port forwarding on the router to receive traffic. You'd like to be able to connect to the public IP but from inside the local network. You need to enable/configure Hairpin NAT on your router, if it's supported. I can't think of any other solutions.

  • Forgive the large edit - I wanted to explain how DNS could be used to accomplish the dual IP resolution and also mention editing the hosts file locally. Feel free to reverse my edit or change it substantially if you prefer. – bmike Apr 14 '16 at 22:37
  • @bmike I doubt that a split-brain setup is possible at all in the case of the asking person. – klanomath Apr 14 '16 at 22:42
  • @klanomath if they must have IP address, then you are correct. No DNS will rewrite an IP. – bmike Apr 14 '16 at 22:51
  • Which is why I didn't go there after his comment on the original post. – samh Apr 15 '16 at 14:00
  • I will actually be able to use character based addresses, so I've understood this correctly then I will be able to set it up? My router sadly doesn't support loopback, which is what lead me here in the first place. I do however only have the one internal DNS server available for configuration, so that will render me with only the host files you speak of, correct? Sorry if my question was unclear in terms of my requirements. – Emil L. Apr 16 '16 at 19:08

One way of resolving this is to add a DNS entry for this IP address, and use the name instead of the IP itself. Since you're connecting via IP, you're never using DNS.

This only works, however, if wherever you're accessing this from internally uses an internally-run DNS server. This would mean that you'd setup server.yourdomain.com on your internal DNS server to point at the internal IP, and server.yourdomain.com on an external DNS server to point to the external IP.

Then, when you try to access server.yourdomain.com inside your network, it resolves via the internal DNS server, and when you try to access from outside of your network, it resolves via the external DNS server.

  • I will be able to use the names instead. But I do however only have control of one external DNS. I supposed that leaves the desired effect unacquireable for me. – Emil L. Apr 16 '16 at 19:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .