Can I stop Nextcloud from trying to use IPv6?

I just installed Nextcloud 25.0.4 on FreeBSD 13.1. I set up an admin account, did all the things that the “Security and Setup Warnings” thing suggested, and then tried to figure out how to install apps. I couldn’t figure out how to do so; what I saw on my “Apps” screen doesn’t seem to correspond to the directions given in the documentation. It only shows a few already-installed apps, which I can enable or disable; it does not, for example, show anything about the app store or anything like “Add a new app”. I then checked config.php to make sure that I wasn’t overriding the default appstoreenabled or appstoreurl options. I am not.

Eventually, I went to the “Logging” screen, where I think I found the issue: There are a whole bunch of the following errors (many of which are coming from the appstore app):

RuntimeException: Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".

I do not have IPv6 set up on my machine. I do not want to set it up on my machine. Is there a way to get Nextcloud to stop trying to use it, and just use IPv4 instead?

OK, I did a little debugging and I now have it working, but in a super-kludgy manner.

The issue is that when Nextcloud looks up DNS for a host name, it does both an IPv4 lookup and an IPv6 lookup. If both worked, it seems like it uses the IPv6 result (at least in some cases - I haven’t looked closely), and if getting to the site via IPv6 fails, too bad, that’s it, no IPv4 attempt for you.

To get it working, I changed lib/private/Http/Client/DnsPinMiddleware.php to ignore IPv6 results, by commenting out a little bit of code inside of the dnsResolve function:

foreach ($dnsResponses as $dnsResponse) {
   if (isset($dnsResponse['ip'])) {
      $targetIps[] = $dnsResponse['ip'];
      $canHaveCnameRecord = false;
   } elseif (isset($dnsResponse['ipv6'])) {
//asdf bob commenting out begin
//      $targetIps[] = $dnsResponse['ipv6'];
//      $canHaveCnameRecord = false;
//asdf bob commenting out end
   } elseif (isset($dnsResponse['target']) && $canHaveCnameRecord) {
      $targetIps = array_merge($targetIps, $this->dnsResolve($dnsResponse['target'], $recursionCount));
      $canHaveCnameRecord = true;
   }
}

Like I said, it’s working now, but it’s super-kludgy. Really (in my opinion) there should be some sort of setting to disable IPv6 lookups.

Is there some standard place I can submit a change request based on this? Thanks.

I have submitted a PR to fix this issue: [Bug]: Should not look at IP v6 DNS records i running in PHP without IP v6 support · Issue #40820 · nextcloud/server · GitHub

1 Like