Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have web site being hosted on my computer, so that mysite.com is served from one of my machines. However, even though everyone else can access this site normally, if I type its name (or, indeed, any subdomain such as x.mysite.com), I can't get the site to show. Now, if I edit the hosts file to redirect mysite.com to 192.168.1.5, everything is fine.

However, this is not a viable solution because then I need to edit the hosts file on every machine on the network. So, my question: is there an easier way?

share|improve this question
    
What router are you using? –  mindless.panda Oct 18 '10 at 19:49
    
If you are using a Linux based router that runs dnsmasq, you can add a hosts file to that and it will work for all machines on your LAN. –  paradroid Oct 20 '10 at 7:22
    
@mindless.panda a dlink router –  Dmitri Nesteruk Apr 22 '13 at 18:08
    
@paradroid no idea if I have that, how can I tell? –  Dmitri Nesteruk Apr 22 '13 at 18:08
    
@DmitriNesteruk You'd know if you did. Some routers can run third-party Linux-based firmware like DD-WRT, OpenWRT and Tomato. –  paradroid Apr 22 '13 at 18:32

3 Answers 3

up vote 2 down vote accepted

Some DSL/Cable routers don't allow these types of loopback connections (when a 'public' URL refers to a device on your LAN) so you may need to find one that does. The Draytek 26xx/28xx/2820 range definitely do.

share|improve this answer
    
Yap - some routers might call it something slightly different than loopback connections, but I highly recommend getting a router that supports this. –  mindless.panda Oct 18 '10 at 19:48

If everyone else can access your site, that means that you have a forward DNS setup somewhere that points that URL to your public IP. If for some reason your computers on your private network are not able to resolve that URL, then the issue is with the DNS entries in your router, or your ISP has some issues, but I'm leaning towards your router at this point. There is no reason that you shouldn't be able to resolve that url if everyone else can, whether you are on the same network or not. If you actually want to resolve it locally (have the url you type resolve to the private IP of the web server instead of the public IP of your network) you will need to use the HOSTS file, or you just could just use the private IP in your web browser instead of a url.

share|improve this answer
    
The address can be resolved just fine. The problem is that most routers redirect accesses to the external address from internal machines to the router itself instead of following the port forwarding rules. –  Ignacio Vazquez-Abrams Oct 20 '10 at 7:22

Add the appropriate entry to whatever local DNS server your local network is using. If your local network isn't using one, then set one up.

share|improve this answer
    
So are you saying my only option is to run my own DNS server? If that's the case, how do I popupate the DNS server with various entries? –  Dmitri Nesteruk Oct 18 '10 at 19:37
    
That's up to the specific DNS server. I recommend dnsmasq if you don't need anything massive. –  Ignacio Vazquez-Abrams Oct 18 '10 at 19:41
    
If his router doesn't support loopback connections (see answer from Linker3000), it won't help him to run a local DNS server, unless he has his DNS server point the domain name to a local IP. –  mindless.panda Oct 18 '10 at 19:49
    
@user26453: You mean like the one he said he's already put in hosts in the question? –  Ignacio Vazquez-Abrams Oct 18 '10 at 19:59
    
hehe yep, much simpler than setting up a DNS server –  mindless.panda Oct 18 '10 at 20:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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