Use local IP when on home network

Is there an option to use the local IP when you’re on a specified network (at home I’m on a different VLAN/subnet, but on the same network), but the FQDN when not? For me, this is specifically for the macOS client as well as the Android “Nextcloud” and “Talk” apps.

This is something that other apps form self-hosted things I use have (e.g. Home Assistant mobile App) which is really neat.

It would mean that (1) even if the internet is out, you still have access while you’re home, (2) no data is sent outside your home when home, and (for my Nextcloud) (3) it would be significantly faster while at home (I see a very noticible difference between using Nextcloud with the local IP and FQDN in browser when at home).

Normally you can configure on your router Definition Hairpinning or NAT Loopback and then you use the same worldwide name cloud.server.tld in your intranet. There are no performance problems. Then you must also use DynDNS, Port Forwarding and Lets Encrypt.

On your clients you only need one name for your nextcloud and it works in LAN, WLAN and Internet.

Oops, didn’t think that one through. A bit pampered by other apps having the option built in, I guess. But I just added a local DNS record to my DNSMasq that handles all DNS anyway :roll_eyes:
Thanks for the pointer

Yes. But if you also have access to your nextcloud through internet with https://cloud.server.tld you can better use the same domain form all places and devices.

I’m not sure I understand what you mean?

After adding a local DNS record in DSNMasq (well, Pihole, but that’s DNSMasq under the hood), when I try:

nslookup next.my_domain.com

It shows the local nextcloud IP when I’m connected to my home network, but my public IP when I’m connected to my mobile hotspot (not home network).

Regardless of whether I’m on the home network or not, I use next.my_domain.com, and I connect just fine.

1 Like

Yes. Normally you use only your name next.my_domain.com You do not need an intern dns entry or another name. It works fine with next.my_domain.com from intern and extern.

That depends on whether the router supports NAT loopback or not :wink: But a local DNS entry is preferable imho. And if @Aephir already has a Pi-hole running anyway, I would definitely use that instead of NAT-Loopback.

Great, I’ll keep the DNS entry as is.

Thanks for the clarification both of you!

1 Like