1

I have a server behind NAT, with IP 192.168.0.42. The router gets a dynamic IP from the ISP, which is regularly used to update a domain, let's say myserver.example.com. The router is configured to forward port 80 to the server.

This works fine externally and the server can be reached under myserver.example.com. However, if I try to access it via that domain from inside the network, it doesn't work. I think what's happening is that the client machine contacts public-ip, but then when the server responds it sends the response directly to the client machine but coming from 192.168.0.42, which results in it being discarded by the client.

Is it possible to set up iptables on the server to detect this and respond correctly to the client? One difficulty is that I don't know what the public IP is. I couldn't find anything on the TP-Link router to fix this.

I know I could put a hosts entry on the client machine but that breaks if it's a laptop and is used externally.

chpatrick
  • 111
  • 1
  • 1
    Does this answer your question? [Loopback to forwarded Public IP address from local network - Hairpin NAT](https://serverfault.com/questions/55611/loopback-to-forwarded-public-ip-address-from-local-network-hairpin-nat) – fuero Feb 14 '21 at 17:02

1 Answers1

0

Disabling "NAT Boost" on the router fixed it.

chpatrick
  • 111
  • 1