This is the situation:

I have a web server on my LAN that serves up beta versions of my documentation for my free software.

This web server, via my router, responds to an external IP address. Imaginary IPs for the purpose of explanation:

  • My web server is on my LAN at
  • My WAN static IP is

Externally, DNS is not set up so that some name resolves to Nor will it be. So you can't get there the usual way.

So, I provide URLs to my beta testers in this form:

This works fine. My testers out in the world can get to my server and all is good. For them.

Here's the problem: on my machine, if I try to get to that URL, for instance, when I click on a link on a web page that contains it, my machine tells the router to NAT to, and that's the end of that - it goes nowhere.

The router does not appear to have any loopback capability to let it know that indeed, is, in fact, on my LAN (although frankly, I think it should know that already, since that's its external IP and that's where I'm trying to get to. It used to work fine on my old router. But anyway.)

So what I'm looking for is a way to tell OS X here on my local machine that when I reach out to, I'm actually trying to reach so that my web server will respond to me here on my machine, directly via the LAN.

Simply put, on my machine only, I need the following,...

...to reach here:

Previously, I had my users set up a hosts file entry for an imaginary servername of the form someweirdname.com, like this... someweirdname.com

...and then put all my links up in the form...


...which actually works fine, but ran into a fairly severe user problem where setting up a hosts file was completely beyond them, hence no access to the docs.

Using the IP requires nothing of the user but clicking the link, and as I said, it works fine for them. But it locks me out, which is highly inconvenient for me - I can't follow URLs out on other web servers back to various places in my beta docs without dragging out my cellphone, turning off its access to wifi, and going after those links via 4G so my router sees the request coming in from outside the LAN.

When I'm just reading my docs here, I just use someweirdname.com to get to them, and it's all relative from there, and that works fine too.

I just can't to them from other server's web pages out on the net. And for... reasons... I need to test those URLs to make sure they go where they are supposed to go.

Is there a solution for this conundrum that doesn't involve buying yet another servername, costing me yet more money to expose my local beta docs, and dealing with the resulting DNS maintainance churn?

I can live with it as it is, and have been, but I hate it.

  • 2
    Why don't you edit your hosts file?
    – klanomath
    Jan 12, 2016 at 18:42
  • I did. Didn't work. See below.
    – fyngyrz
    Jan 13, 2016 at 23:34
  • This is asking for some major network breakage to get the system to ignore and instead do a DNS lookup. What's the reason for not making the link a DNS name - even using a free dynamic DNS service so that you can put a name there and use the normal hosts file trick?
    – bmike
    Jan 14, 2016 at 16:20
  • Your post is a bit unclear: You say your web server is responding to a public IP address, but the description doesn't really match. Your router has a public IP, and everything behind is NAT'd through that, right? What model router do you have—it probably will require custom configuration to achieve what you want.
    – samh
    Jan 14, 2016 at 16:23
  • @samh That might work - program the router to intercept the outgoing packet and instead have a "next hop" at the local server IP?
    – bmike
    Jan 14, 2016 at 16:31

3 Answers 3


Arpanet: At Work Since 1969 - editing your own hosts file is the method of choice.

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##   localhost broadcasthost
::1 localhost
fe80::1%lo0 localhost


# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##       localhost  someweirdname.com www.someweirdname.com broadcasthost
::1 localhost
fe80::1%lo0     localhost

You might have to flush the DNS cache using sudo killall -HUP mDNSResponder and sudo dscacheutil -flushcache.

  • No, doesn't work. Same result: nothing comes back. weirdname.com comes back, but the IP does not.
    – fyngyrz
    Jan 13, 2016 at 21:40
  • the host pings fine. the LAN IP pings fine. The website works fine. But my browser can't get to the WAN IP from inside the LAN. **the WAN IP pings fine INSIDE the network, so apparently the modem is forwarding... but the DNS stuff is somehow not happening
    – fyngyrz
    Jan 13, 2016 at 23:21
  • ok, and the ping went right there. So... apparently the hosts table thing IS working, but not through the browser. I mean, it's one hop. So that's right to the machine.
    – fyngyrz
    Jan 13, 2016 at 23:24
  • also perhaps of interest, wget can't see the server at the WAN IP either. it sees it fine at the LAN IP.
    – fyngyrz
    Jan 13, 2016 at 23:30
  • @fyngyrz you are right with the 200... entry in the hosts file. It doesn't work! But i will find another solution. What's your OS X version?
    – klanomath
    Jan 14, 2016 at 8:14

Your only hope to me seems to make a static route on your Machine to have routed to but I'm guessing that won't work without some network trickery on the web server side to actually listen to the packets instead of routing them on to the router that has issues on your client.

In the interim, you might try setting up a free dynamic DNS service to associate with a host name that will resolve for all your external testers to the IP you choose for the server.

Then you can avail yourself of the normal editing of /etc/hosts trickery to have that name resolve to your choice of internal IP rather than going to the DNS servers in general.

Basically move away from hard coding the IP address into the URL and use a name that you can override more easily.

  • Many ISPs have DNS entries that will point to the IP address, like aa.bb.cc.dd-isp-name-location.net or something similar, where the public IP is aa.bb.cc.dd or dd.cc.bb.aa. In that case, his users could use the DNS name for his router and he could set his hosts file to the private IP address… right? Since it sounds like a dynamic DNS name is not what he wants.
    – samh
    Jan 14, 2016 at 16:26
  • @samh My understanding is the OP wants one URL that can be published/embedded into documents or code that resolves to one IP address for most users and to another IP address for himself. A real DNS name would be better than dynamic dns, but those aren't free and simple to set up in 30 minutes time. The aa.bb.cc.dd-isp-name-location.net will break for external users since they can't route to as it is a non-routable IP.
    – bmike
    Jan 14, 2016 at 16:29
  • Users don't need a route to Right now those users are going to and it works. Changing nothing, they should be able to go to 200-100-50-25.myisp.region.net/mybetadocs/webpage.html and it should work. Then fyngyrz just adds an entry for that address in the hosts file pointing to and his computer won't ever hit the gateway for that traffic.
    – samh
    Jan 14, 2016 at 20:58
  • I'm working this. I can't seem to find that kind of DNS with my ISP, so I've oped a techj ticket with them asking what the deal is. Will get back here when I know more.
    – fyngyrz
    Jan 15, 2016 at 23:46

It's not the ideal solution and doesn't solve any of the actual problems per se, but if all you want is to leave everything as is and have a way to test the links, you could initiate a VPN connection. At that point, you should be able to hit your public IP from outside and port forwarding will work the way you want it to.

You must log in to answer this question.

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