Lukas Z's Blog

Mini-Guide: How to Run Pi-Hole on a Synology NAS

I installed Pi-hole, the adblocking DNS server, on my Synology NAS machine, and since it wasn’t as straightforward as I had hoped, here’s a mini guide that I want to share.

Step 1: Install Container Manager

Container Manager

Go to your synology console (for me it’s at http://synology.local:5000 in my home network) and install the app “Container Manager”. It allows us to run Docker containers on the NAS.

If you are asked anywhere if it should run as root, say yes.

Step 2: Create two folders

Go to File Station and create those two folders:


/docker/pihole/etc-pihole
/docker/pihole/etc-dnsmasq.d

Step 3: Run Pi-hole in a Docker container

Open Container Manager and create a new project. I have used this YAML-configuration.


services:
  pihole:
    image: pihole/pihole:latest
    network_mode: host
    container_name: PiHole
    restart: unless-stopped
    mem_limit: 1g
    cpu_shares: 90
    environment:
      - PIHOLE_UID=1024
      - PIHOLE_GID=101
      - TZ=Europe/Berlin
      - FTLCONF_webserver_api_password=<SET_YOUR_OWN_PASSWORD_HERE>
      - FTLCONF_webserver_port=8080
      - IPv6=False
      - DNSMASQ_LISTENING=all
      - DNSMASQ_USER=root
    volumes:
      - /volume1/docker/pihole/pihole:/etc/pihole
      - /volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d

And then run it.

For me this worked, but it could be that your UID and GID are different. Here’s how I found out what mine are:

Optional Step: Find UID and GID

I connected with ssh into the nas, in my case the command was:


ssh admin@synology.local

and then I just ran


id

And then just adjust the values accordingly.

Final words

By configuring your home router or access point to assign DHCP leases with your Pi-hole DNS server as the primary resolver, any device that requests an IP address (computers, phones, etc.) will automatically begin using your Pi-hole DNS service.

P.S.: You can follow me on Twitter.

Comments

Webmentions