I can't get my server to contain local traffic

Hello. I have a HomeDrive NUC and I’m trying to route my local traffic directly to it instead of through the web. I read the HomeDrive FAQ and followed their instructions to edit the hosts file so it would include the server local IP address and its web domain at the very end:

127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

127.0.1.1 burmilla
192.168.0.130 https://{my.domain).com

However, when I disconnect the WAN ethernet cord from y ISP router, my Nextcloud clients have no connection.

Autocleaning the trashbin doesn’t work either but I was told that this is a standard feature which works on all other Nextcloud servers. I’m just a layman at this stuff but could these two issues be related somehow? They both involve editing some sort of configuration file on the server but nothing happens.

Thanks in advance for any help.


DETAILS

Yes, this is the first time I’ve encountered this problem since it’s the first time I’ve tried making this sort of change.

Nextcloud version: 25.03

OS for network devices: Linux Mint 20.3 and 21

Sorry, I don’t know how to find out what php version I have or if I’m using Apache or nginx.

I generated a log file but it’s 70 mb, plus I’m not sure if I can redact all the personal info out of it. If you wan’t me to share a link to it, I’ll try cleaning it.

The hosts file is for overriding DNS. It can’t process protocols or URLs. This line should read:

192.168.0.130 my.domain.com

I just tried that but no change. Does the server need to be rebooted?

EDIT: Just rebooted my server but no luck.

When you do that, can you still ping this IP address?

Yes. Here’s a snippet of the output.

ping 192.168.0.130
PING 192.168.0.130 (192.168.0.130) 56(84) bytes of data.
64 bytes from 192.168.0.130: icmp_seq=1 ttl=64 time=4.04 ms
64 bytes from 192.168.0.130: icmp_seq=2 ttl=64 time=2.96 ms
64 bytes from 192.168.0.130: icmp_seq=3 ttl=64 time=1.22 ms
64 bytes from 192.168.0.130: icmp_seq=4 ttl=64 time=1.37 ms
64 bytes from 192.168.0.130: icmp_seq=5 ttl=64 time=5.10 ms
64 bytes from 192.168.0.130: icmp_seq=6 ttl=64 time=4.55 ms
64 bytes from 192.168.0.130: icmp_seq=7 ttl=64 time=3.28 ms
64 bytes from 192.168.0.130: icmp_seq=8 ttl=64 time=8.14 ms
64 bytes from 192.168.0.130: icmp_seq=9 ttl=64 time=12.3 ms
64 bytes from 192.168.0.130: icmp_seq=10 ttl=64 time=13.4 ms
64 bytes from 192.168.0.130: icmp_seq=11 ttl=64 time=3.98 ms
64 bytes from 192.168.0.130: icmp_seq=12 ttl=64 time=5.01 ms
64 bytes from 192.168.0.130: icmp_seq=13 ttl=64 time=8.90 ms
64 bytes from 192.168.0.130: icmp_seq=14 ttl=64 time=4.54 ms
64 bytes from 192.168.0.130: icmp_seq=15 ttl=64 time=10.6 ms
64 bytes from 192.168.0.130: icmp_seq=16 ttl=64 time=3.37 ms
64 bytes from 192.168.0.130: icmp_seq=17 ttl=64 time=6.37 ms

@rtevans
Unfortunately, I didn’t quite understand your problem. But I think it is always a bad idea to change anything in /etc/hosts. How do you do it on your smartphone in the home network?

It’s actually normal that the data is routed past the WLAN router in your case. You could search for hairpinning and NAT traversal.

What is the web? Where is the web? Or do you use something like Cloudflare?

You did edit this file on your computer, correct? Not the server? The hosts file only affects the device where it is changed.

You’re right. I just edited the hosts file on the server instead of on my devices. Show what I know.

Anyway, after editing it on my machines and disconnecting my ISP router, the clients would connect but not sync. When I tried connecting through SSH, it would take a while but would eventually connect. I finally tried deleting the var, config, and cache files for Nextcloud on my Linux desktop devices, set up the clients again, and it worked! They can sync over my LAN now.

I guess the next question I have is how do I know if my devices are syncing over LAN or WAN? Will they default to LAN instead of WAN if the LAN is available? Another question is how do I edit the hots files on my Android devices without root?

You could search for hairpinning and NAT traversal.

I did some research on NAT reversal, hairpinning, and came across DNSmasq. I just downloaded a software package for DNSmasq to my OpenWRT router. It looks like there’s a settings page for it. Am I on the right track? Might be above my head and I’d hate to screw something up at that level but I’ll make backups of my router config just in case.

If I reconnected my server to the OpenWRT router, I’d probably have to do everything over again since the IP address would change, right?

What is the web? Where is the web? Or do you use something like Cloudflare?

I guess by web I mean WAN. More specifically, HomeDrive’s Fabrics service.

Using your local hosts file(s) on your clients to keep the trafic on LAN, when your devices are on LAN, is not a good practice.
When you brings your devicc outside your LAN, they will be unable to connect, as outside your LAN, your devices will be on a different network, hence the chance that there even is a Nextcloud (or that your devices is even on a subnet where your hosts file believes the DNS address is located) is not even worth mentioning. Hence you would need to manually change your hosts file on each device each time you brings it outside your local network.

For anything working solid, you will need a local DNS server on your LAN, which is also given to all clients through your DHCP, so that it will give the local IP when asked to translate your domain to an IP, and when outside, it will be the public IP given by a public DNS server.

1 Like