Pihole update: how to retain my dnsmaq settings (dhcp, interaface etc.)

Hi forum,

I got away with updating to pihole 2.9.2 and have all running without any issues.
Running raspberry and using dnsmasq to serve dhcp.(and a whole lot off other stuff like privoxy and also nxfilter on a second network interface)
In the past, after updating pihole, to restore my personal dnsmasq settings was to overwrite 01.pihole.conf with my former one.
Now I noticed with version 2.9.4 (pihole -up=> keep settings) somehow I am no longer able to edit dnsmasq settings to enable my custom settings. All custom settings are ignored.
I did read a post about setupvars.conf, but that layout is not suitable for adding my settings.
So basic :
Q1: how can I edit dnsmasq settings so I can re-enable my custom settings:
(Interface, dhcp server, wpad etc. etc. etc.) and keep pihole working also off course.
q2: is there an option to keep my settings with future updates, as pihole update destroys custom dnsmasq settings.everytime.
Perhaps an extra include in dnsmasq.conf for custom user settings?

Exactly this! Any changes made to 01-pihole.conf will be overwritten with every update. v2.9.5 / v2.10 will have a warning at the top of the file like this.

If you want to add in your own configs, then either add them into /etc/dnsmasq.d/ directory (e.g 02-custom.conf) or make your changes in /etc/dnsmasq.conf, which we do not touch on install/update.

Thanks and OK....

However: your 01-pihole.conf always includes "listen address 127.0.0.1"
And that's exactly the line I need to have disabled.....I need dnsmasq to bind only to eth0 and not on 127.0.0.1
Would a second conf overrule that?
Is there a sequens of reading the conf files..So if I would name my config:
00-custom.conf would that load first?

While typing I am also making a copy of sd card and try this myself and run a pihole -up and see what happens.

Is the listen-address line causing issues?

In my case it is.
I have nxfilter running on eth4 on the same box.
Need to insulate dnsmasq to eth0 otherwise nxfilter can not use port 53 on eth4.
This is how you do that:
01-pihole.conf:

# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
interface=eth0
except-interface=eth1
except-interface=eth4
except-interface=wlan0

# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)
# listen-address=127.0.0.1
bind-interfaces

# Set the cachesize here.
cache-size=10000

# For debugging purposes, log each DNS query as it passes through
# dnsmasq.
log-queries
log-facility=/var/log/pihole.log

# Normally responses which come from /etc/hosts and the DHCP lease
# file have Time-To-Live set as zero, which conventionally means
# do not cache further. If you are happy to trade lower load on the
# server for potentially stale date, you can set a time-to-live (in
# seconds) here.
local-ttl=300

# This allows it to continue functioning without being blocked by syslog, and allows syslog to use dnsmasq for DNS queries without risking deadlock
log-async

# From here entries from Jeroen
local=/noads.local/
domain=noads.local
address=/raspberry.noads.local/192.168.1.2
address=/wpad.noads.local/192.168.1.2
address=/wpad/192.168.1.2
dhcp-authoritative
#dhcp-range=set:red,192.168.1.100,192.168.1.199,255.255.255.0,72h
dhcp-range=set:red,192.168.1.100,192.168.1.199,255.255.255.0,365d
dhcp-option=tag:red,6,192.168.1.4,192.168.1.2,208.67.222.222,8.8.8.8
dhcp-option=tag:red,option:router,192.168.1.1
# dhcp-option=tag:red,option:ntp-server,192.168.1.2
dhcp-option=19,0
dhcp-option=42,0.0.0.0
dhcp-option=44,192.168.1.2
dhcp-option=45,0.0.0.0
dhcp-option=46,8
all-servers
txt-record=wpad,"service:wpad:!http://192.168.1.2:80/wpad.dat?"
srv-host=wpad.tcp.wpad,wpad.wpad,80
srv-host=_wpad._tcp.192.168.1.2,wpad.192.168.1.2,80
dhcp-option=252,"http://192.168.1.2/wpad.dat?"

After last update of pi-hole for some reason dnsmasq totaly ignores these settings
Even if I just overwrite 01-pihole.conf.
Just as if dnsmasq is getting some other config.........
But that should not even be possible.
Weird he:)

(Just a hint, if you're pasting in a config file/code use the preformated text button on the editor, it makes things easier to read!)

If I were you, I'd split the DHCP stuff out into a seperate config file...

@singularity, I seem to recall a while back we talked about removing the listen-address line from 01-pihole.conf ? Or was I imagining that?

Will try to split all my settings into 00-custom.conf and pray this overrules listen-address in 01-pihole.conf.
Time will tell if this works.
Need to make a copy of sd card first as there is no option to do a system restore:)
Then I will do a pihole -up and will let you know the outcome.

Dnsmasq reads the files in order, so you might want it to be 02-something.

dnsmasq ignores listen-address if you have an interface directive.

# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)

Oh! So it's completely redundant in 01-pihole.conf anyway, then?

It might be a flag that is ripe for culling in a test branch/PR...

Made a 00-custom.conf with my settings and used original 01-pihole.conf and all seems fine with this version.
Making another backup and update pihole tomorrow.

1 Like

00 will be overwritten by 01. It's lexicographic, so name it 99 to make it last applied.

Good morning,

So the results:
Creating 99-custon.conf in etc/dnsmasq.d solved my dnsmasq issues after the pihole update.
Rasp still nicely serving dhcp and all my settings work.
Now the bad news:(
Pihole -up also "destroys" /etc/lighttpd/lighttpd.conf
Not sure if there is a similair trick with a second conf file.
The only line I need (back) in lighttpd.conf is this:
server.bind = "192.168.1.2"

A fix for that issue is in development. We should have something worked out in the next few release cycles.

Can you run a pihole -d for us, I'm curious about a configuration flag with the 99. And can you include the contents of the 99-config.conf file?

Working on your request.
Give me a few minutes

No problem, I'm headlining here all week... Remember to tip your waitresses!

pihole -d:
http://termbin.com/dvc8

99-custom.conf

# Pi-hole: A black hole for Internet advertisements
# (c) 2015, 2016 by Jacob Salmela
# Network-wide ad blocking via your Raspberry Pi
   # http://pi-hole.net
# dnsmasq config for Pi-hole
#
# Pi-hole is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# If you want dnsmasq to read another file, as well as /etc/hosts, use
# this.
# addn-hosts=/etc/pihole/gravity.list

# The following two options make you a better netizen, since they
# tell dnsmasq to filter out queries which the public DNS cannot
# answer, and which load the servers (especially the root servers)
# unnecessarily. If you have a dial-on-demand link they also stop
# these requests from bringing up the link unnecessarily.

# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
# bogus-priv

# If you don't want dnsmasq to read /etc/resolv.conf or any other
# file, getting its servers from this file instead (see below), then
# uncomment this.
# no-resolv

# Add other name servers here, with domain specs if they are for
# non-public domains.
# Iserver=208.67.222.222
# Iserver=208.67.220.220

# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
interface=eth0
except-interface=eth1
except-interface=eth4
except-interface=wlan0

# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)
# listen-address=127.0.0.1
bind-interfaces

# Set the cachesize here.
# cache-size=10000

# For debugging purposes, log each DNS query as it passes through
# dnsmasq.
# log-queries
# log-facility=/var/log/pihole.log

# Normally responses which come from /etc/hosts and the DHCP lease
# file have Time-To-Live set as zero, which conventionally means
# do not cache further. If you are happy to trade lower load on the
# server for potentially stale date, you can set a time-to-live (in
# seconds) here.
# local-ttl=300

# This allows it to continue functioning without being blocked by syslog, and allows syslog to use dnsmasq for DNS queries without risking deadlock
# log-async

# From here entries from Jeroen
local=/noads.local/
domain=noads.local
address=/raspberry.noads.local/192.168.1.2
address=/wpad.noads.local/192.168.1.2
address=/wpad/192.168.1.2
dhcp-authoritative
#dhcp-range=set:red,192.168.1.100,192.168.1.199,255.255.255.0,72h
dhcp-range=set:red,192.168.1.100,192.168.1.199,255.255.255.0,365d
dhcp-option=tag:red,6,192.168.1.4,192.168.1.2,208.67.222.222,8.8.8.8
dhcp-option=tag:red,option:router,192.168.1.1
# dhcp-option=tag:red,option:ntp-server,192.168.1.2
dhcp-option=19,0
dhcp-option=42,0.0.0.0
dhcp-option=44,192.168.1.2
dhcp-option=45,0.0.0.0
dhcp-option=46,8
all-servers
txt-record=wpad,"service:wpad:!http://192.168.1.2:80/wpad.dat?"
srv-host=wpad.tcp.wpad,wpad.wpad,80
srv-host=_wpad._tcp.192.168.1.2,wpad.192.168.1.2,80
dhcp-option=252,"http://192.168.1.2/wpad.dat?"

Install log

:::
::: Installing scripts to /opt/pihole... done.
:::
::: Installing configs...
:::    Existing dnsmasq.conf found... it is not a pi-hole file, leaving alone!
:::    Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf... done.
:::
::: Creating log file and changing owner to dnsmasq... already exists!
:::
::: Installing pihole custom index page... Existing page detected, not overwriting
::: Installing sudoer file... done!
:::
::: Installing latest Cron script... done!
::: Configuring iptables for httpd and dnsmasq..
:::
::: Preparing to run gravity.sh to refresh hosts...
::: Cleaning up previous install (preserving whitelist/blacklist)
::: Running gravity.sh
:::
::: Neutrino emissions detected...
:::
::: No custom adlist file detected, reading from default file... done!
:::
::: Existing pihole directory found
:::
::: Getting raw.githubusercontent.com list... List updated, transport successful!
::: Getting mirror1.malwaredomains.com list... List updated, transport successful!
::: Getting sysctl.org list... List updated, transport successful!
::: Getting zeustracker.abuse.ch list... List updated, transport successful!
::: Getting s3.amazonaws.com list... List updated, transport successful!
::: Getting s3.amazonaws.com list... List updated, transport successful!
::: Getting hosts-file.net list... List updated, transport successful!
::: Getting raw.githubusercontent.com list... List updated, transport successful!
::: Getting ransomwaretracker.abuse.ch list... List updated, transport successful!
::: 
::: Aggregating list of domains... done!
::: Formatting list of domains to remove comments.... done!
::: 125437 domains being pulled in by gravity...
::: Removing duplicate domains.... done!
::: 101349 unique domains trapped in the event horizon.
::: Formatting domains into a HOSTS file...
:::
::: Adding 9 adlist sources to the whitelist... done!
::: Running whitelist script to update HOSTS file.... 12 domains whitelisted!
::: Running blacklist script to update HOSTS file.... 10 domains blacklisted!
:::
::: Cleaning up un-needed files... done!
:::
::: Refresh lists in dnsmasq...