bbnn bbnn - 1 year ago 81
Apache Configuration Question

Apache unable to access local DNS ip address

I just set up a server in my house using private IP.

I can access my server using my domain from outside network/ outside from my house.

But I cannot access it from local network using my domain or my private IP address.

What can be the problem for this? is it the Apache settings?

(I can access it if I edit the /etc/hosts file)

Answer Source

Did you use the internal or external IP in your hosts file to get it working? If it was external IP it's probably the DNS issue. If it was the internal IP, the issue could be in the routers NAT.

Some routers/setups will only apply their NAT rules on packets traversing the external internet facing interface.

                |            |       
Server ---IntIf-|IntIP--ExtIP|-ExtIf--- Internet

This is a bit simplified but basically when you access the external IP from the internal network the packet, following the dotted line, reaches the routers external IP before a NAT rule can be applied on ExtIf and then the router can't find anything listening so rejects/drops the connection.

To confirm if it is the DNS problem. Run an nslookup $domain from both your local and external boxes and see if they return the same IP address. If the IP's are the same and it's still not working you will need to take a closer look at the router, hopefully that's possible. If not you may need an internal DNS server that can respond with the internal IP addresses for any domains it knows about then forward any other requests externally.

The NAT issue is called NAT Loopback, Hairpinning or Reflection. See here for a linux solution.