Now got Pi-hole running in LXC container

I currently have my pi-hole running on a Pi2 and have been looking to migrate it into the TrueNAS server for a while

What I do/did want is an easy way to have both boxes use the same IP so that any hardcoded entries looking for DNS don’t have to change

Plus In the event that the TrueNAS is down for a period of (un)scheduled Maintenance I can just fire up my PI and everything just works

Here’s what I did

1 - Created a network bridge

2 - set all LXCs to use the bridge interface (you may not need this)

3 - Created a LXC with

4 cores ← probably overkill 2 should be enough

4GiB RAM ← probably overkill 2 should be enough possibly even 1

Debian Bookworm

4 -open shell

5 - apt install nano curl these are needed for following steps

6 - set static IP

nano /etc/systemd/network/eth0.network

[Network]

DHCP=false

Address=<your static IP> / < your subnet e.g 24>

Gateway=<your router/gateway>

^X and save

7 - curl -sSL https://install.pi-hole.net | bash

from pi-hole github and let it do its thing

Then I used teleporter to move my settings, if you’re setting up for first time follow standard instructions

1 Like

Nice work. You can also just create a 2nd pihole dns and set it as a secondary dns resolver. This way you can just have both up at the same time if you want. I have found that dns resolution will timeout at times when the primary dns resolver goes down extensively. In such a case, you can swap the secondary to the primary so that it attempts to resolve there first.

I run multiple pinhole here that I advertise via DHCP in the gateway. It allows maintenance, updating the blocklists, etc without interrupting anyone. Running instances on different hardware platforms hopefully improves reliability also.