2

It seems that this question is very similar to I suddenly can’t access my own web server within my LAN via the external WAN IP address but nothing there helped me so I'm trying again.

I have a router with WAN address 1.2.3.4 and local network 192.168.1.1/24. I have a web server running on 192.168.1.100.

In router settings, I have changed the port of management panel from 80 to 81 not to interefere with the webserver. Then I have added a port forwarding rule for TCP 80 -> 192.168.1.100:80. Finally, I have assigned a domain name example.com to 1.2.3.4 so accessing example.com correctly routes to my web server. From the world.

However, when I try to enter the example.com from any of the devices connected to the 192.168.1.1/24, it does not work.

I tried to diagnose it with ping, and the domain correctly resolves to the IP address so it seems like not a DNS problem:

root@linux:~# ping example.com
PING example.com (1.2.3.4) 56(84) bytes of data.
64 bytes from 1.2.3.4.ip4.feromedia.eu (1.2.3.4): icmp_seq=1 ttl=63

Also, traceroute stops at the router:

root@linux:~# traceroute example.com
traceroute to example.com (1.2.3.4), 30 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 0.350 ms 0.256 ms 0.195 ms
2 * * *
3 * * *
4 * * *

I have found neither NAT Loopback nor NAT reflection settings in my router as suggested in the question linked above. I have not configured anything in the static routing and I can't remember anything I could done that would cause such behavior.

My router is DrayTek Vigor2925.

2

Your router probably doesn’t support NAT Loopback (A.K.A NAT Hairpinning). Upgrade to an aftermarket firmware distro (such as LEDE), or replace your router with something that has factory firmware that supports NAT Loopback (such as an Apple AirPort Base Station).

  • AFAIU, the NAT Loopback is an enhancement that allows not to go outside my LAN network if the target device is already there. If there is not NAT Loopback - the request should go out and then came back. Am I missing something? – fracz Sep 25 '17 at 22:56
  • 2
    @fracz Once your router does outbound NAT on the packet, the packet’s source and destination addresses are both set to your router’s public WAN IP address. There’s nowhere “outside” for your router to send it to. Your router needs to be smart enough to do outgoing and incoming NAT on the same packet because no one else is going to do it for you. That’s what NAT Loopback is. It’s not an enhancement, it’s the only way this can work. – Spiff Sep 25 '17 at 23:26
2

As @Spiff suggested, the problem is probably in lack of support for NAT Loopback.

However, I have managed to handle this situation with static DNS entry in my router configuration. In DrayTek it is known as LAN DNS feature and AFAIU, it is similar to an entry in the hosts file on the machine.

After adding a 192.168.1.100 example.com entry there, my router started to respond with a LAN 192.168.1.100 address for the example.com DNS query for every device in my network. Therefore, they are able to reach the local webserver by the domain name although my router does not support NAT Loopback globally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.