How to access a site you host from within your own network?

1

1

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?

Dmitri Nesteruk

Posted 2010-10-18T19:26:02.603

Reputation: 372

What router are you using? – mindless.panda – 2010-10-18T19:49:56.310

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 – 2010-10-20T07:22:43.507

@mindless.panda a dlink router – Dmitri Nesteruk – 2013-04-22T18:08:35.997

@paradroid no idea if I have that, how can I tell? – Dmitri Nesteruk – 2013-04-22T18:08:57.047

@DmitriNesteruk You'd know if you did. Some routers can run third-party Linux-based firmware like DD-WRT, OpenWRT and Tomato. – paradroid – 2013-04-22T18:32:14.710

Answers

2

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.

Linker3000

Posted 2010-10-18T19:26:02.603

Reputation: 25 670

Yap - some routers might call it something slightly different than loopback connections, but I highly recommend getting a router that supports this. – mindless.panda – 2010-10-18T19:48:54.927

3

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.

Ignacio Vazquez-Abrams

Posted 2010-10-18T19:26:02.603

Reputation: 100 516

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 – 2010-10-18T19:37:17.793

That's up to the specific DNS server. I recommend dnsmasq if you don't need anything massive. – Ignacio Vazquez-Abrams – 2010-10-18T19:41:03.493

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 – 2010-10-18T19:49:33.440

@user26453: You mean like the one he said he's already put in hosts in the question? – Ignacio Vazquez-Abrams – 2010-10-18T19:59:44.000

hehe yep, much simpler than setting up a DNS server – mindless.panda – 2010-10-18T20:23:25.580

@user, he said in the question he doesn't want to change the hosts file for every computer 'cos not feasible. Clearly setting up his own DNS server is cheaper than buying a new router. What he could do is run a script to copy an amended hosts file to every computer on the network, then automatic, and feasible. – barlop – 2010-10-19T22:08:03.973

1

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.

MaQleod

Posted 2010-10-18T19:26:02.603

Reputation: 12 560

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 – 2010-10-20T07:22:31.797