Pihole 6 docker custom local dns file

Hello everyone,

I am a Pi-hole 5 user, which I installed with Proxmox.

I had a 4-line script that performed a completely automatic, unattended installation.

It retrieved two files, setupVars.conf and custom.list, which were dynamically created using DNS/IP aliases from my database, which was super convenient. If I needed to, I could run the script, and it would automatically update my dynamic DNS. Plus, I could see them in the UI.

Since upgrading to version 6, nothing works. I’m trying to use Docker since the automatic version no longer seems to work, and I want to configure a custom DNS file and see it in the UI, but it’s impossible… I saw that dnsmasq needs to be enabled, but with Docker, it’s not working.

Honestly, I find it disappointing—I really feel like the new version is a step backward on some very useful features…

How can I fix this please ?

What have you tried? :slight_smile:

For Docker, the recommended way of persisting your configuration is to use environment variables. This ensure that you have a repeatable config that remains fairly static no matter where you spin it up (obvious exception of this is persisting the sqlite databases, which will require volume mounts)

For local DNS records you can add them to the environment in your docker compose file like:

environment:
    FTLCONF_dns_hosts: '127.0.0.1 google.com;127.0.0.2 facebook.com'

edit:

You can also add them like this if you have many and want it to be easier to read in the compose file - and each one will work, but currently they will look odd on the UI

environment:
  FTLCONF_dns_hosts: |
      127.0.0.1 google.com
      127.0.0.2 facebook.com
      127.0.0.3 somethingelse.com

As a side note:

For a bare metal install, the --unattended flag still works, but things have changed since v5. The new config file is named pihole.toml. If you preseed this file and place it in /etc/pihole/pihole.toml - you can run the install script on a fresh system with the --unattended flag and it will read in the pre-seeded values.

The equivalent to custom.list in this case would be adding the local records to dns.hosts and dns.cnameRecords within the toml:

[dns]
  # Array of custom DNS records
  # Example: hosts = [ "127.0.0.1 mylocal", "192.168.0.1 therouter" ]
  #
  # Possible values are:
  #     Array of custom DNS records each one in HOSTS form: "IP HOSTNAME"
  hosts = [
    "127.0.0.1 google.com",
    "127.0.0.2 facebook.com"
  ] ### CHANGED (env), default = []

Hello,

Thanks for your message, and sorry for the weird characters in my previous one.

Indeed, with my old setupVars.conf, I used to define my DNS settings, network interface, and the web interface password. So, I found the corresponding variables for Docker, and it works.

However, my issue is setting the DNS entries “permanently” in the config file because before, I only had to copy a file to update the list of entries.

How can I modify the local DNS entries via the command line once the Docker container is installed?

If you need to be setting these DNS entries frequently and dynamically, maybe the environment variable is not the best for this - as anything set by environment variable becomes read-only, so as to establish a single source of truth.

However, command line is also achievable:

pihole-FTL --config dns.hosts "127.0.0.1 google.com;127.0.0.2 facebook.com"

I have tried to add this compose.yaml

services:
  pihole:
    hostname: pihole
    container_name: Pihole
    restart: unless-stopped
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      TZ: 'Europe/Paris'
      FTLCONF_dns_listeningMode: 'all'
      FTLCONF_misc_etc_dnsmasq_d: 'true'
      FTLCONF_webserver_api_password: 'PIHOLE_PASSWORD'
      FTLCONF_dns_upstreams: 'DNS_PRINCIPAL;DNS_SECONDAIRE'
    volumes:
      - 'FOLDER_DNS:/etc/dnsmasq.d'
      - 'FOLDER_PIHOLE:/etc/pihole'

I create a custom.list in /etc/pihole like before, and I set

addn-hosts=/etc/pihole/custom.list in /etc/dnsmasq.d/custom.conf

It works, and I can juste update custom.list, reloaddns and its done.

But I cant see it in admin panel, or mobile app.
Is it a good practice ? Tanks again

If it works for you...

Yeah, that's another way to do it. Just, like you say, they're not in the the web interface - but that's because the web interface does not know about this file.

Only thing important for me, once server is installed, its to update records with simple plan text file.
It s sad they cant be managed by admin ui :slight_smile:

Why not just directly edit the correct key in the toml file? Sure, you need to add quotes and around each line and add a comma - but at least then you can also see them on the web interface...

[dns]
  hosts = [
    "127.0.0.1 google.com",
    "127.0.0.2 facebook.com"
  ] 

Also if you want a way of just pasting in a list on the web interface - toggle the "Expert" mode, and then go to Settings -> All Settings -> DNS Server -> dns.hosts

and you can just paste them in and save

This could be great. And I can see/édit in ui admin ?
I dont need docker with your solution. Just unattended install with env variables dns and password ?

Can I push an empty model of toml file that I complète or edit the curent file with Fresh install is better ?

Bécause to have a preseed install without interactiion, I have to init a file, where can I get a clean proper file ?

I finally got it !
with empty preseed toml file, it's work like a charm !

[webserver]
  api_password = "PIHOLE_PASSWORD"
[dns]
  upstreams = [
    "DNS_PRINCIPAL",
    "DNS_SECONDAIRE"
  ]

and finally this for update all hosts :

pihole-FTL --config dns.hosts '["127.0.0.1 google.com", "127.0.0.2 facebook.com"]'

thanks you very much

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.