Pi-Hole & Nextcloud (Same Pi)

Hi,

I have a Pi 5 on which I've installed Nextcloud. I also have a Pi 3 on which I have Pi-Hole. I would like to integrate both on the same machine i.e. migrate (reinstall) my pi-hole to the same Pi 5. I've imaged my Nextcloud server chip so I should be covered.

This is my planned process of installation:

  1. Enter admin mode:
    sudo su2
  2. Ensure latest files installed:
    apt update && apt upgrade -y
  3. Install Pi-Hole (accept all defaults):
    curl -sSL https://install.pi-hole.net | bash
  4. Reset pi-hole password:
    pihole -a -p

Current pi-hole is on a different internal IP to my Nextcloud... do I just add an IP using nmtui or should just use the same IP (pi-hole uses lighttpd as it's web server rather than Apache so I'm guessing the two wouldn't conflict anyway).

I'm a retired Windows tech and not all that au fait with Linux (I know some but it's all a bit basic).

Thanks :slight_smile:

James

OK,

That all went swimmingly (can you tell I'm British?) except it "thinks" it's on one IP and I want it on another. The Pi has two IPs configured and I wanted one configured for Nextcloud, the other configured for Pi-Hole and currently both are configured for the same IP.

I've looked around obvious folders such as /etc/pihole but found no configuration files mentioning IP (inc. /etc/pihole/setupVars.conf). I've also run pihole -r and selected "Reconfigure" but that just runs the configuration wizard and doesn't appear to allow for an IP change.

One idea occurred... I could temporarily remove the Nextcloud IP (using nmtui), run the wizard (pihole -r) to force it to x.x.x.4 then add the IP again. Would that work (would Pi-Hole then stick to the other IP)?

Thanks

James

This may invite port conflicts over ports 80 as well as 53, in case Nextcloud would not only run run its own web server, but also a DNS server or a stub resolver.

You may want to consider to also raise your question with Nextcloud support, as their user base may already be familiar with potential issues and adequate mitigation approaches.

How did you define those IPs?
Are they bound to a specific network interface each?

I don't understand.

OK. I don't think I was clear enough in that it (the Pi 5) was already configured with Nextcloud and then I installed Pi-Hole on it. In other words:

  1. Configure Pi 5 with Nextcloud (say, IP: x.x.x.82)
  2. Add additional IP (say, IP: x.x.x.92)
  3. Install pi-hole (pi-hole adopts x.x.x.82 when I actuallty wnat it to go go to x.x.x.92).

No, just added to the same interface (eth0) using nmtui.

James

If Nextcloud comes with a webserver claiming port 80 and a DNS service claiming port 53, this may prevent those services or Pi-hole to start successfully, depending on whichever is first to claim those ports.

Port 53 is specifically prone here, as pihole-FTL (a tailored fork of dnsmasq) defaults to binding the wildcard address 0.0.0.0, even when it is listening on only some interfaces, and discarding requests not arriving on those configured interfaces.

Pi-hole allows to change that behaviour by binding to a specific network interface instead, by switching its Interface settings to Bind only to interface xxx via Settings|DNS.

However, that would only work if your IP addresses would be tied to different network interfaces.

I have had both running on an RPi, however, I had them as Docker containers.

You could set them up as macvlan or ipvlan to give each container it's own IP address to avoid port conflicts or alternatively alter the ports exposed by the container(s).

Docker has other advantages to running on bare metal, I now run all services, such as PiHole, as Docker containers on the Pi.

Hi Guys,

Looks like I did it by removing the Nextcloud IP, reconfiguring Pi-Hole then re-adding the Nextcloud one although it didn't until I put them back in the same order as before... not sure why that was an issue.

But yeah, success.

I am, however, going to re-investigate Docker as I think it might be a better way forward than the way I'm doing things now.

Thanks for your help :slight_smile:

James

Not sure if this is true... maybe if you use macvlan, but you will need to learn how to configure the network to achieve your goal.

When you use docker macvlan network mode you don't need to configure different IPs in the same interface. The macvlan will supply each container an individual IP in the same network as your host. Since each container has its own IP, there are no port conflicts.

You can search the web for "docker macvlan". Here are some old links I found:

1 Like