I have a mix of wireless and wired clients, including a wired home server. Previously, I had a single router, a TP-Link Archer C7 running OpenWRT. I was able to access my server from the internet via port forwarding, and I also had NAT hairpin/loopback working configured. i.e. I could access my server via its domain name, from both from outside or inside my local network.
I have now set up a MikroTik RB5009UG+S+IN as my main router. This connects directly via ethernet to various computers including the home server. Our wifi is provided by a Synology RT2600ac, which is connected to the MikroTik, and set to access-point mode.
My home server is accessed externally through foo.bar.com. I have several rules on the MikroTik that forward http(s) traffic to the server (192.168.1.91). e.g.
/ip firewall nat
add action=dst-nat chain=dstnat dst-port=80 in-interface-list=WAN protocol=tcp to-addresses=192.168.1.91 to-ports=80
add action=dst-nat chain=dstnat dst-port=443 in-interface-list=WAN protocol=tcp to-addresses=192.168.1.91 to-ports=443
I can access this domain name when connecting from outside the LAN. It also works well for clients within the LAN, but only when these are wired directly to the MikroTik router. If clients within the LAN connect via the Synology wifi router, I can no longer access the server via domain name.
If I ping from a wired client, it connects directly to the internal IP.
$ ping foo.bar.com
PING foo.bar.com (192.168.1.91) 56(84) bytes of data.
64 bytes from foo.bar.com (192.168.1.91): icmp_seq=1 ttl=64 time=0.255 ms
If I ping from a wireless client, it only sees the external IP.
$ ping foo.bar.com
PING foo.bar.com (<external IP>) 56(84) bytes of data.
64 bytes from <my ISP's domain name> (<external IP>): icmp_seq=1 ttl=64 time=3.96 ms
I can also ping the internal IP 192.168.1.91 directly from the wireless client.
The wired connection works fine even if I don’t explicity set up NAT hairpin/loopback. FWIW I tried setting it up anyway, but this did not help with the wifi clients. (I’m not even sure why the wired client works with my current setup, with pings going to the correct internal IP. I only have specific ports forwarded to the internal 192.168.1.91. Pings don’t have ports, so I don’t understand why this traffic is getting redirected to this address.)
I’ve checked the settings of the Synology wifi router, and there doesn’t seem to be anything there that is useful. In any case, since it’s in access-point mode, presumably the pertinent settings are in the MikroTik router. To confirm that the MikroTik router was probably what needed to be configured correctly (and not the Synology wifi router), I tested with my old Archer C7 that used to allow connecting to the server. I kept all the old settings, except set it to access-point mode, then connected it to the MikroTik router. When connecting to the Archer C7 SSID, NAT hairpin now did not work. This suggests to me that the problem lies with the main MikroTik router.
How can I access the server from the wireless LAN via its domain name?