I have a NextCloudPi server at my house. I have an No-IP address for DDNS access from outside the LAN. The external address works (I can access the server through a browser on my phone, and I can make a NextCloud client account on my Mac that works from outside.)
I have set up my Mac with an /etc/hosts entry for the external address, and that works: I can use the external address within the LAN, both in the client and for browser access. It does not work on my phone or a second Mac that doesn’t have the hosts entry: the browser waits for a minute or so and then responds “Safari can’t open the page (url) because the server where this page is located isn’t responding” or something slightly less helpful in DuckDuckGo on the phone.
(caveat: I haven’t yet tried using the external address from the Mac with the hosts entry from outside the LAN: I can imagine that the hosts entry messes that up, but I don’t know yet.)
I would like to set up the router and the NextCloudPi so that they handle this loopback. That way, I won’t have to fiddle with /etc/hosts on each machine in the LAN that needs to do this.
I feel like I’ve tried a dozen different things over the last month and none of them have worked: fiddle around with dnsmasq on the server, set up a virtual server on the router, … The admin page for dnsmasq says “Remember to point your PC and devices DNS or
your router DNS to your NCP IP” but I don’t know how to do that.
The router is a bit older, a Tp-Link Archer C7, but it has built in support for No-IP, and that all seems to work. Its documentation for NAT forwarding is not helpful.
This way over DNS is the right way to go to make it work on all devices:
You went the right way. If the dnsmasq is running on the server, you have to check the router settings, the DHCP section, the DHCP on the router promotes one or several DNS servers/resolvers. Often it is the ip of the router itself, or one of your provider. This one you have to change to your dnsmasq server’s ip.
Some open router software (OpenWRT) already integrate dnsmasq or similar services. Not sure if your router can work with such a firmware. By the way, a nice open source router: Turris Omnia - Wikipedia (they based their firmware on openwrt).
Thanks tflidd. Still a work in progress. I tried the easiest thing with the router (to put the NextCloud server address as primary DNS on the DHCP page) but that made the router stop working. Am taking a break for now, will come back if I make any progress.