No internet access if DNS is pointing to pi-hole

The issue I am facing:
No internet access when DNS is set to Pi-Hole Static IP
Details about my system:
running pi-hole v5.2.2
Everything runs fine until I change my routers DNS to pi-hole (192.168.1.10)
I cannot even run pi-hole -d as it wont upload (Tried via web portal as well.)
What I have already tried:
/flushdns, /release, /renew,
restarted DNS resolver from web GUI among other things that I cannot recall right now.
Since I cannot upload the logs and provide a token, I will post it here.

Please help!

Debug log removed by moderator and made private.

Thank you for removing the log.
I could not find the edit button :slight_smile:

You have some connectivity problems on the Pi. Something is interfering with outgoing port 53 traffic, it appears.

*** [ DIAGNOSING ]: Operating system
[i] dig return code: 10
[i] dig response: dig: couldn't get address for '[ns1.pi-hole.net](http://ns1.pi-hole.net)': failure

*** [ DIAGNOSING ]: Name resolution (IPv4) using a random blocked domain and a known ad-serving domain
[โœ“] [guanjia.baidu.com](http://guanjia.baidu.com) is 0.0.0.0 via localhost (127.0.0.1)
[โœ“] [guanjia.baidu.com](http://guanjia.baidu.com) is 0.0.0.0 via Pi-hole (192.168.1.10)
[โœ—] Failed to resolve [doubleclick.com](http://doubleclick.com) via a remote, public DNS server (8.8.8.8)

From the Pi terminal, what are the outputs of the following:

ping -c3 8.8.8.8

dig pi-hole.net @8.8.8.8

dig pi-hole.net @127.0.0.1

1 Like

Thank you for your response!

root@DietPi:~# ping -c3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.1.10 icmp_seq=1 Destination Host Unreachable
From 192.168.1.10 icmp_seq=2 Destination Host Unreachable
From 192.168.1.10 icmp_seq=3 Destination Host Unreachable

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 107ms
pipe 3
root@DietPi:~# dig pi-hole.net @8.8.8.8

; <<>> DiG 9.11.5-P4-5.1+deb10u2-Raspbian <<>> pi-hole.net @8.8.8.8
;; global options: +cmd
;; connection timed out; no servers could be reached
root@DietPi:~# dig pi-hole.net @127.0.0.1

; <<>> DiG 9.11.5-P4-5.1+deb10u2-Raspbian <<>> pi-hole.net @127.0.0.1
;; global options: +cmd
;; connection timed out; no servers could be reached
root@DietPi:~#

That confirms no port 53 connectivity.

How do I remedy that?

I have internet if I dont set the DNS to Pi-Hole

I have added the Diet Pi tag to your post. If the Diet Pi developer sees it he will reply.

Or post the issue here: GitHub ยท Where software is built

I appreciate it!!

Thank you for your help.

@Freedomunit Meanwhile, you could post the output of

sudo iptables -L --line-numbers

so we can check if it is a firewall issue.

Hhm @DL6ER this is what I get when I run it in pi-hole

root@DietPi:~# sudo iptables -L --line-numbers
sudo: iptables: command not found

Fixed!

It was my default gateway.

Was somehow set to 192.168.0.1

I manually edited it using nano /etc/network/interfaces

Thanks for all your help!

1 Like

Sorry for my (too) late reply :slightly_smiling_face:. Strange that with wrong gateway it was even possible to install Pi-hole. Did you use the static IP already before or applied it afterwards?

Is iptables really not there?

Not pre-installed on DietPi.

Why not?

You know, we usually ask "why", instead of "why not", when it's about additional packages. A firewall needs to be configured protective to be effective and when it is, for every additional software that sends and/or listens, you need to allow it explicitly, which is a hurdle for inexperienced users, that e.g. install Pi-hole and then wonder why it's not working since inbound port 53 is blocked. So we'd need to add rules for every software title and somehow prominently inform users that and how to change rules for every port change or additional port use.

Secondly, in very most cases, the NAT/router servers as a sufficient natural firewall, of course only against access from www, not local network, and yes I know a NAT is strictly not a firewall.

But most importantly I see not much reason for running a firewall on a system where you exactly know which inbound ports are used. By default DietPi ships with SSH server, nothing else that listens on any network interface/port. So you could configure to allow inbound port 22 and nothing else, but why blocking all other ports when there is nothing that listens on them anyway? As fast as you install an FTP server that uses port 23, you anyway want to allow it in the firewall, so again it has no effect on that port. So firewalls only make sense if you run software that you do not trust (including outgoing connections) or cannot control in other ways (e.g. bind it to a specific interface, but all relevant software I know allow doing such). Running software that you do not trust, should not be done anyway, and otherwise via systemd unit setting those can be hardened or castrated much more effectively, selective and much wider (system file/command access etc).

If one really needs and knows how to configure a firewall as protective as possible but as permissive as required, running apt install iptables should not be an issue, and for traffic forwarding (hotspots, VPN servers) we install and configure it automatically.

So, in order to install the firewall to protect the host from the internet, you need to connect to the internet and expose it?

And we usually error on the side of being too safe than free balling to the world.

That's the whole point of a firewall, to protect you from the things you DON'T exactly know.

Sorry, but that's a really shortsided choice to remove iptables. I'll never use DietPi.

DietPi follows the philosophy to have as few things pre-installed as possible so that we in fact exactly know what is installed and listening. All that can be connected to on first boot is port 22, and that is practically required, as we ship images for a lot of headless devices, or for convenience to avoid the need to connect monitor + keyboard.

I agree that an additional security layer is not a bad idea, but you need to configure it yourself, we cannot automate or predict what will be used or required or what would break the usage. Many distros (by far no all) ship with iptables installed by default, but unconfigured, so it has zero effect until the admin manually configures it. And every reasonable guide instructs to run apt update; apt upgrade as the very first action after booting a fresh OS, so the situation is exactly the same as when booting DietPi the first time. If you need to configure iptables before even plugging the Ethernet cable or connecting to WiFi, then indeed with DietPi you'd need to place the DEB package onto the SD card/drive manually before booting it.


Btw, don't misunderstand me, I totally agree that there are security-related things that we need to improve, or add optionally, but a firewall is IMO the least important one. There are other topics, like AppArmor, not shipping with two login users (where one could be forgotten or never recognised, while it can be used via SSH), making the use of VPNs, HTTPS and SSH key-authentication easier. I'd rank that higher, considering what risks and capabilities an average user of us has.

They come with iptables unconfigured, yes, but you don't have to connect to the internet in order to get the package to configure it. That's closing the barn doors after the horses have bolted. You're making a ton of assumptions on your part and that's highly dangerous. You assume the image is okay, you assume the packages you source are okay, you assume that there are no 0 day exploits on your build system.

You don't have firewalls for things you know, you have firewalls to protect you for the things you don't know.

Dismissing security because it's inconvenient is a very bad practice.

Again, I'll never use it and I'll never suggest anyone else use it either if your view is "but it's too hard.."

Sorry for getting a bit personal here, knowing that this will throw back our lately positive developing relationship, but as you obviously couldn't resist making and repeating an absolute statement against DietPi, I cannot let such uncommented.

Either you rate different aspects of a systems security very differently than me/us, or you drop and raise your standards depending on your current discussion position or with whom you are discussing. I saw enough examples to believe that the letter is not an unrealistic theory. Since I'm a bullhead, likely I behave similar by times, without recognising, but on the firewall topic you'll find my above statements in at least two other places, where it was about offering a firewall as install option via our UI, doing more than "apt install iptables", not about having the package pre-installed. On a Windows system, bloated with closed-sourced applications and features, in-transparent, but constant network traffic to and from various, by me only partly known, hosts, similarly default cheesy perforated firewall rules, I see things completely different and would clearly agree with you. But the FOSS upstream-side development, Debian-side review, testing and compiling, stable suite APT downstream installs is an overall infrastructure that I trust enough to see no need for a pre-installed firewall in let's say 99% of use cases we address.

But as you made such an absolute statement, I'm curious how you set your standards when it's about Pi-hole's security:

If it's a definite requirement for you to configure a firewall before connecting a freshly flashed Linux distro to the internet, then I wonder how you need to rate the obvious security "weaknesses" (quoted, as I see them relative only and not as real issue) that Pi-hole is installed with:

  • It's shipped with plain HTTP webserver configuration, making it even difficult to switch to HTTPS as the main configuration is overwritten on each update. I know the three years old community guide, containing correspondingly outdated TLS protocol and cipher settings, with forced cipher order, so that modern Lighttpd defaults and client preferences are weakened. Yes, admins with sufficient knowledge who require elevated security can set this up themselves, but after initial install, the web interface is "exposed".
  • This plain text web interface can be initially accessed by a password that is printed two times in plain text to the console during Pi-hole install and of course is then transmitted as plain text from client to server. What a theoretical security issue until the admin manually shuts down the webserver or changes the password. Of course one could setup a firewall to block port 80 before installing Pi-hole (not sure if the installer would go through?), shutdown and configure Lighttpd to use HTTPS and preferably change the password, then unblock port 80 and 443 to allow web UI access. Sounds pretty much like the little extra work that you'd need to do on a fresh DietPi image to have iptables available prior to first network connection.
  • Pi-hole is shipped with a blocking page that can be accessed without network restrictions and leaks server information, including the private IP address, in certain circumstances, all again in plain HTTP by default. Since you plan to remove most parts of the blocking page, reasonably IMO, I did not report this issue, until the planned change has been finished. Since the blocking page is only relevant when actively used by changing the blocking mode and for clients which actually use Pi-hole for DNS resolving (usually private networks only), Lighttpd could be easily configured to prevent accessing it from non-private IP ranges by default and prevent access completely when using a different blocking mode.
  • The web UI checks the client-controlled "host" header against a list of authorised hostnames/IPs, but includes Lighttpd's server name in this list without giving it a server name in the shipped configuration. In such case, Lighttpd automatically assigns the client-controlled host header value as server name, which renders that check obsolete. To be fair, this does not include CORS via HTTP_ORIGIN if used by the initial client, which still prevents effectively against bad proxies/rewrites.
  • The Lighttpd user is granted root permissions to execute the pihole script. What an attack vector!
  • And did you know that DietPi addresses most of the above, as it allows to enable modern HTTPS easily, blocks non-private IP range access to the blocking page by default, allows to do the same for the admin UI and re-applies a user-chosen encrypted password for accessing it? The one optional feature breaks access to the Pi-hole admin panel when the local subnet does not use an IP range that is officially reserved for private networks, and in case of a user report in this forum you would blame us for this, while using such an IP range for ones private network can be seen as security issue by itself: security vs convenience for end user and/or support team.

I don't think it makes sense to invest development time into the above points, as most will be obsolete anyway once Pi-hole has the webserver with PHP included into the FTL binary. Let's have a look at that:

  • Your plan is to merge a PHP implementation that has not seen commits for three years, is based on ancient EOL PHP 5.3 and that uses a single huge source file without any visible unit tests. You are talking about protection from "things you don't know" and bring a huge rarely used and hence rarely reviewed or tested code block into your project, behind any firewall and with elevated permissions for a quite sensitive network service. I can understand and agree with the reason in this particular case, but from a strict security perspective, breaking admin's possibility to use and configure modern, maintained and well-known webserver and PHP implementations for using the Pi-hole web UI, is a step backwards.

You know why I would still recommend Pi-hole? Because all the above is not an issue in 99% of use cases and considering the users you mainly address and the possibilities that every admin still has to manually harden Pi-hole and system security where required. In an environment I can think of where a missing pre-installed iptables is a killer argument against using a distro/image, I'd not recommend to use any public distro image but bootstrap it in an offline environment from double-checked local repositories. I would never install Pi-hole on such sensitive system, and for DNS-based ad blocking I'd use a block list to Unbound rules converter and do all of that with Unbound only to skip all the possible attack vectors that a webserver, PHP, additional dnsmasq, system user and overall increased complexity that Pi-hole implies.

It is all about the use case and individual needs and a long-sighted security strategy, from developers view as well as from system admin view, always requires a balance between security and convenience for the average user that is addressed. Products are not used when being too inconvenient, making users migrate/stay with less secure alternatives, additional security measures get disabled or worked around, like too similar or written down passwords, in case of forced rotation, 2FA via same device as client, at best with passwords stored in browser, proprietary cloud password manager solutions in general, etc. Pi-hole implies a lot of complexity, theoretical attack vectors and weakened security for basically convenience features on top of its core functionality, mostly addressing lesser experienced users, which is fine as in very most cases, blocking bad websites increases overall user security much more then the above mentioned points, and the easy install and convenience is what made it so popular, even that other much safer and less complex solutions exist.

Another thing: If you quote me, please use the words I used and do not take them out of context. I never wrote that my or our view about a firewall is that "it's too hard" and I'm not even sure what you are referring to with this quote. I made clear that we do not pre-install iptables since for users that need it and know how to configure it it's not a bid deal to install it, even prior to first network access, where really required. If there was a single actual user complaint, I'd more likely re-consider it, as there is also no real argument against pre-installing that little, by default passive package, to be true.

Okay, help me out of the mud, I still love Pi-hole and you guys for developing this great project and the awesome end user support you do, which is kind of exceptional, the above was mostly a defence reflex :slightly_smiling_face:.