Pi-hole with LXD - Installation and Setup

Pi-hole is wrapper of your DNS server that block all advertisements and trackers. We're using it at our home network to block all those unnecessary bandwidth wasting contents. Setting up for any of your devices is quite straightforward, just make sure your router point to it as DNS server.

While there is a Docker image existed, we have installed it within a LXD container since we have a LXD host exists in our small homelab server, Kabini (more on this in coming posts).

First we setup the container based on Ubuntu 18.04.
$ lxc launch ubuntu:18.04 pihole
$ lxc list -c=ns4Pt
+--------+---------+----------------------+----------+------------+
|  NAME  |  STATE  |         IPV4         | PROFILES |    TYPE    |
+--------+---------+----------------------+----------+------------+
| pihole | RUNNING | 10.53.105.102 (eth0) | default  | PERSISTENT |
+--------+---------+----------------------+----------+------------+

Looking at the table above, notice that container created based on the default profile, the IP we obtained is within the 10.x.x.x range. What we need to do is to change to create a new profile which will enable the container accessible to other in the LAN network. Hence, we need to switch from bridge to macvlan.

The `eth0` network adapter links to your host's network adapter, which can have different naming. For example, `enp1s0` (LAN). However, you can't bridge a Wifi interface to ethernet interface as Wifi by default, only accept a single MAC address from a client.
$ lxc profile copy default macvlan
$ lxc profile device set macvlan eth0 parent enp1s0
$ lxc profile device set macvlan eth0 nictype macvlan

Stop the `pihole` container so we can switch the profile to `macvlan`.
$ lxc stop pihole
$ lxc profile apply pihole macvlan
Profiles macvlan applied to pihole
$ lxc start pihole
$ lxc list
$ lxc list -c=ns4Pt
+--------+---------+----------------------+----------+------------+
|  NAME  |  STATE  |         IPV4         | PROFILES |    TYPE    |
+--------+---------+----------------------+----------+------------+
| pihole | RUNNING | 192.168.0.108 (eth0) | macvlan  | PERSISTENT |
+--------+---------+----------------------+----------+------------+

Next, enter the container and install Pi-hole.
$ lxc exec pihole bash
[email protected]:~# curl -sSL https://install.pi-hole.net | bash

No comments:

Post a Comment