I'm having this issue as well.
When I change 'Interface Listening Behavior' to option 2 or 3, it does fix the issue temporarily until I reboot the machine. I have to 'Restart DNS Server' after every reboot before Pi-hole will respond to DNS queries.
I'm having this issue as well.
When I change 'Interface Listening Behavior' to option 2 or 3, it does fix the issue temporarily until I reboot the machine. I have to 'Restart DNS Server' after every reboot before Pi-hole will respond to DNS queries.
I'm not sure if I have written that down here somwhere. The problem with the fist option is that the implementation in dnsmasq v2.72 is broken. Unfortunately, this is the version that is shipped with Raspbian Jessie.
I haven't noticed, since I have a modified version of dnsmasq compiled from source (v2.76) on my Pi. This version works also absolutely flawlessly with the first option.
Sorry, I should have provided more info.
I'm running Pihole on Lubuntu 16.04.02 LTS. Running dpkg -s dnsmasq shows version 2.75
Okay, so e.g. setting 2 should create a line like
interface=eth0
in your /etc/pihole/setupVars.conf. Is this line still there after you reboot?
Also, what is the output of
sudo service dnsmasq status
when it does not work?
Using interface setting 2, the following line is in /etc/pihole/setupVars.conf before & after a reboot
PIHOLE_INTERFACE=enp1s0
Output of sudo service dnsmasq status after reboot
pihole01@TMS-Pihole01:~$ sudo service dnsmasq status
[sudo] password for pihole01:
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
Drop-In: /run/systemd/generator/dnsmasq.service.d
└─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
Active: failed (Result: exit-code) since Thu 2017-03-16 10:46:11 CDT; 45s ago
Process: 795 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)
Process: 774 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
Mar 16 10:46:11 TMS-Pihole01 systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Mar 16 10:46:11 TMS-Pihole01 dnsmasq[774]: dnsmasq: syntax check OK.
Mar 16 10:46:11 TMS-Pihole01 dnsmasq[795]: dnsmasq: unknown interface enp1s0
Mar 16 10:46:11 TMS-Pihole01 systemd[1]: dnsmasq.service: Control process exited, code=exited status=2
Mar 16 10:46:11 TMS-Pihole01 systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
Mar 16 10:46:11 TMS-Pihole01 systemd[1]: dnsmasq.service: Unit entered failed state.
Mar 16 10:46:11 TMS-Pihole01 systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
That means that your Ethernet device is actually not there at the time dnsmasq starts, so it is a problem of your system. Is it a virtual server? It might be necessary to edit the start script of dnsmasq and add a sleep statement that delays the start of dnsmasq a few seconds until we can be sure that the interface is actually there.
If you later restart dnsmasq, then your interface is there and hence it will work.
Nope, no virtual server, running on a small Intel Atom machine.
Tried adding sleep 3 (and 5, 10, 20) to the beginning of /etc/init.d/dnsmasq, but none seemed to fix issue.
After=network-online.target
Wants=network-online.target
to the [Unit] section of /lib/systemd/system/dnsmasq.service
Thanks for your help!
Any idea if this will get overwritten with pihole or dnsmasq updates?
dnsmasq: YesIf you edited the service file directly, then it can be overwritten on upgrade of dnsmasq. Instead of editing the systems service file, either use a drop in snippet or an override, explanation here.
Perfect, thanks for the info!
Removed those lines from /lib/systemd/system/dnsmasq.service
Using overriding command arguments
sudo systemctl edit dnsmasq
Then add
[Unit]
After=network-online.target
Wants=network-online.target
Write out & exit. Rebooted and confirmed dnsmasq starting without issue.
Same problem, running Ubuntu 16.04. After a reboot I have to run pihole restartdns to get things working correctly. I have Listen only on interface eth0 selected in advanced DNS settings.
Debug log is js28lmtrzf.
Edit: can also confirm that the solution posted by @ljmunz fixes the issue!
Edit 2: For posterity I'll add that of course this isn't a permanent solution, because i.e. updating dnsmasq might very well overwrite your changes to dnsmasq.service. But it's fine as a temporary solution until a fix is made in pihole.
The override suggestion that @DanSchaper suggested will still work after an upgrade:
This is more of a bug in Ubuntu's config for dnsmasq than Pi-hole.