Connection Problem after 4.3.3 & 4.3.5 update with PiVPN

Cheers, thanks. I'll have a proper look at that output tomorrow once I have more time to sort through it.

I genuinely appreciate all the time that's being spent on my issue.

See output from the grep command below. I recognise all the static address definitions and have just left the Pi4 in for clarity.

/etc/dnsmasq.conf:conf-dir=/etc/dnsmasq.d
/etc/dnsmasq.conf.old:conf-dir=/etc/dnsmasq.d
/etc/dnsmasq.d/01-pihole.conf:addn-hosts=/etc/pihole/black.list
/etc/dnsmasq.d/01-pihole.conf:addn-hosts=/etc/pihole/gravity.list
/etc/dnsmasq.d/01-pihole.conf:addn-hosts=/etc/pihole/local.list
/etc/dnsmasq.d/01-pihole.conf:bogus-priv
/etc/dnsmasq.d/01-pihole.conf:cache-size=10000
/etc/dnsmasq.d/01-pihole.conf:dhcp-ignore-names=tag:hostname-ignore
/etc/dnsmasq.d/01-pihole.conf:dhcp-name-match=set:hostname-ignore,localhost
/etc/dnsmasq.d/01-pihole.conf:dhcp-name-match=set:hostname-ignore,wpad
/etc/dnsmasq.d/01-pihole.conf:domain-needed
/etc/dnsmasq.d/01-pihole.conf:interface=eth0
/etc/dnsmasq.d/01-pihole.conf:localise-queries
/etc/dnsmasq.d/01-pihole.conf:local-ttl=2
/etc/dnsmasq.d/01-pihole.conf:log-async
/etc/dnsmasq.d/01-pihole.conf:log-facility=/var/log/pihole.log
/etc/dnsmasq.d/01-pihole.conf:log-queries
/etc/dnsmasq.d/01-pihole.conf:no-resolv
/etc/dnsmasq.d/01-pihole.conf:server=127.0.0.1#5353
/etc/dnsmasq.d/01-pihole.conf:server=8.8.4.4
/etc/dnsmasq.d/01-pihole.conf:server=8.8.8.8
/etc/dnsmasq.d/01-pihole.conf:server=/use-application-dns.net/
/etc/dnsmasq.d/02-ovpn.conf:interface=tun0
/etc/dnsmasq.d/02-pihole-dhcp.conf:dhcp-authoritative
/etc/dnsmasq.d/02-pihole-dhcp.conf:dhcp-leasefile=/etc/pihole/dhcp.leases
/etc/dnsmasq.d/02-pihole-dhcp.conf:dhcp-option=option:router,192.168.1.1
/etc/dnsmasq.d/02-pihole-dhcp.conf:dhcp-range=192.168.1.2,192.168.1.254,24h
/etc/dnsmasq.d/02-pihole-dhcp.conf:domain=lan
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=<<Entries here redacted>>
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=*******
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=DC:**:**:**:**:**,192.168.1.239,Pi4
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=
/etc/dnsmasq.d/04-pihole-static-dhcp.conf:dhcp-host=

Above the culprit/rogue file giving you unexpected behaviour.
Try run below one before and after you change "Interface listening behavior" to see difference:

sudo grep '^\s*interface=\|^\s*except-interface=' -R /etc/dnsmasq.*

Ps. can you enclose code output with the "</>" button when pasting here please.
Easier to read and doesnt get mangled by discourse formatting.

OK, here are the results - not sure I understand them though.
Output from the command with listening only on eth0: All networking functions working.

sudo grep '^\s*interface=\|^\s*except-interface=' -R /etc/dnsmasq.*
[sudo] password for  
/etc/dnsmasq.d/01-pihole.conf:interface=eth0
/etc/dnsmasq.d/02-ovpn.conf:interface=tun0

Output from the command with listening on all interfaces. Internet access only via VPN

 sudo grep '^\s*interface=\|^\s*except-interface=' -R /etc/dnsmasq.*
/etc/dnsmasq.d/02-ovpn.conf:interface=tun0

It looks like the 01-pihole.conf file no longer specifies any network interface.

Yes, when Listen All is used then there is no need to specify an interface. But the tun0 locks everything to that specific interface. Our (Pi-hole) config is overriden.

Ahhh!
That explains exactly why it works when I connect via the VPN.

So in your opinion, is there now a case to modify the settings behaviour so the config file explicitly states the allowed interfaces if the 'all interfaces' option is selected?
It's not something I've come across in any of the guides which recommend using PiHole and PiVPN together.

No, there should be no interfaces listed if you want every interface used.

Any guide that recommends adding /etc/dnsmasq.d/02-ovpn.conf is wrong.

3 Likes

Thanks for the clarity.

So going forward, would you recommend removing the etc/dnsmasq.d/02-ovpn.conf file and changing back to all interfaces?

Yes, that is what we've suggested with our documentation.

1 Like

https://docs.pi-hole.net/guides/vpn/overview/

@ramset That is the correct version of the docs, right?

Yes the docs are correct. We reverted that hiccup a while back :slight_smile:

2 Likes

Thanks again to everyone. I've now got it running with all interfaces selected. Had a bit of a false start by me just renaming the etc/dnsmasq.d/02-ovpn.conf file in the dnsmasq.d directory. Hadn't realised it would scan and process any filename in that folder. Deleting it completely did the trick.

2 Likes

About that:
PiVPN adds this file (and line to listen for tun0) automatically during installation if you have Pi-Hole set to "Listen only on eth0". However having Pi-Hole set to "Listen on all Interfaces" will make PiVPN Installer ommit this line in the file.

I've come across this as I read up on the whole thing yesterday as I was trying to understand it. So what you are saying would only be true if Pi-Hole is indeed set to "Listen on all Interfaces" where it doesn't need to specify the new interface explicitely or am I wrong?
Isn't this just the lazy approach, security wise? Instead of having it only listen to eth0 and explicitely allowing another Interface (for VPN) just permitting everything in dnsmasq? Even if the PI isn't exposed to the Internet.

I think any guide that recommends this just assumes you have your Pi-Hole set to only listen on eth0 because thats the default option, isn't it (haven't installed it for a long time so I'm not sure).

I dont know if PiVPN is aware of how Pi-hole is configured.
But this added PiVPN directive is cripeling the ability to set listening behavour on the Pi-hole web GUI.
What if you have a third or fourth interface eg. eth0, wlan0, tun0, wg0 etc. ?
I know its security practice to restrict to whats only needed.
But Debian, and many others, dont restrict interfaces for the dnsmasq package as its just forwarding DNS upstream.

I run the v4 setup yesterday and currently default is "Listen on all interfaces".
I believe it used to be "Listen only on interface eth0" or whatever interface was set during setup.

EDIT: ow and Pi-hole already got a guide to setup OpenVPN without the need of a full distro to do that:

https://docs.pi-hole.net/guides/vpn/overview/

1 Like

Yes, I get what you are saying, however I still believe a lot of people (including myself) will use PiVPN.
PiVPN should at least be able to tell how Pi-Hole is configured in that regard according to that Fix Pi-hole support when dnsmasq is set to listen on all interfaces · pivpn/pivpn@87cf243 · GitHub

Bottom line: As you are also saying, in the past Pi-Hole set it to eth0 only while Pi-VPN needed to add this line to function. As that seems to have changed it might not be necessary anymore. However PiVPN for example doesn't have Upgrade Functionality so that might contribute that problems arise due to mismatching configuration because it was installed in the past where the PiVPN installer handled it differently.

Interface configuration is dynamic. Dropping a configuration file during installation is not sufficient. PiVPN should not add the file. If that configuration line is required for PiVPN to work then their users need to be told to add that. Adding the file without users knowing it causes problems as they have no idea (like in this case) that the file was added.

Edit: I can update the debugger to search for that file specifically and flag if it exists. Our instructions to users will be to remove that file.

Yes, I see that this can problematic when users don't know about that file.
So going forward if I Understand you correctly, your suggestion when using PiVPN would be:

  1. set Pi-Hole to listen to all Interfaces
  2. remove the interface line from the file PiVPN creates. Because actually the file serves another purpose if I understand that correctly (show the Hosts correctly), for example my file looks like that for now:
addn-hosts=/etc/pivpn/hosts.openvpn
interface=tun0

Correct?

Best would be to read Redirecting... and understand our guide for OpenVPN integration. That should answer any question you have on what we suggest and what we rely on.

1 Like

K, got it, so this is basically the only way it should be done.

It's the only way that Pi-hole will provide support for.

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