MacOS – OS X Server DNS, on local network redirect external IP to internal IP

dnsmacosNetworkserver.app

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?

Best Answer

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 94.2.3.4
  • name.pretendco.com 192.168.3.4

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.