0

I have a domain, example.com and it has a A record pointing to my external IP. Port 80 is forwarded to my server. However, when I try to access it from inside the local network (behind the external IP) I can not connect. (Not only for that port, but everything) This does work externally (Port forwards are set up correctly)

Can someone explain me why this is? (Does this have something to do with my router?) Right now, I've solved this problem using a change in my hosts file, so it points to the internal IP, but I would like to know why I had to do this.

Is there a non-hacky way to fix this? So devices in my local network can also access the server using the domain name (without having to make any changes)?

woutwoot
  • 13
  • 6

1 Answers1

1

It is something your router needs to do - its often called "Hairpin NAT" or "NAT loopback". If your router supports it, enabling that should make everything just work. On some its a global setting, others you need to set it on each NAT rule.

If your router doesnt support that, the next simplest way is split DNS. This requires setting up a local DNS server for local machines to use with all the same records as your public DNS has. But for the servers that are on the LAN, you change to using the private IP address. This method has the downside of needing to maintain two sets of SNS records.

Grant
  • 17,859
  • 14
  • 72
  • 103