Question

I have a machine running lighttpd to allow me to do a small scale web-based project. Up until now I've been accessing the project by using the private IP of the machine running lighttpd. The problem I have is that if I disconnect the server and attempt to run my code to test for all cases is realize that the site hangs (after an AJAX call) instead of returning a 404 error because of the direct IP.

Besides for ensuring that the server never goes offline, how can I make sure that the website won't hang up. Is there a way for me to look up the private IP but going through a DNS Lookup to ensure that if it isn't there I don't try to load it anyways.

Was it helpful?

Solution

If it is a unix-compatible resolver (Linux, *BSD etc.), just add an entry to your private IP in into /etc/hosts, following the same format of the other entries of the file. Like this:

10.0.1.6       my_private_host_name

That solution will only work individually on the machine you changed the /etc/hosts file.

Your second option is to create a private-DNS-server and add the your.domain.internal domain to that DNS, and enable DNS forwarding to your internal network, and set your clients to use that DNS server. This way if you try to call your private domain, your DNS server will be SOA (Start of Authority) and answer for it, but if you ask for something that it isn't SOA for it will just pass your request to the old DNS server, that will answer it the usual way.

Now if you need to use a "real" DNS name for your private IP (I want it it to answer on www.my_company.com), the first /etc/hosts method will do the trick,but if you need to set up a DNS server, follow the tutorials on "Split DNS".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top