1

I have setup Pi-hole and some other things on a Debian server, using docker.

The pi-hole is acting as a DNS for my entire network (I have added the server's IP in my router DNS config).

Problem is that I have no internet when Pi-hole is down.

For example when I do some adjustments to my docker compose I need to shut it down.

Is there a way to bypass the pi-hole DNS, only on the server that is running on?

I know google has some DNS servers on 2.2.2.2 and 2.2.4.4. How/where to configure those?

1 Answer 1

2

The 2.2.*.* network segment belongs to Oracle America Inc; Google's public IPv4 DNS servers are 8.8.8.8 and 8.8.4.4.

Since you've told your router to use the pi-hole as a DNS server, it probably distributes that information to your network using DHCP.

To bypass that, you'll need to configure the Debian server to ignore DHCP-provided DNS server(s) and configure it to use something else. How to do that depends on how your server's IP configuration is managed.

With NetworkManager

If your installation includes a graphical desktop environment, it probably uses NetworkManager by default.

If you are using NetworkManager, you should start by finding out the connection name. You can do it with nmcli connection show and looking at the active connections (= those with the DEVICE field not blank, and usually listed in green). If this command produces just an error message, then you are probably not using NetworkManager and should skip this chapter.

Then you'd set that connection to ignore DHCP-specified DNS servers with:

nmcli connection modify "<your connection name>" ipv4.ignore-auto-dns yes

And then configure some custom DNS servers to use, e.g. Google's public DNS servers:

nmcli connection modify "<your connection name>" +ipv4.dns 8.8.8.8
nmcli connection modify "<your connection name>" +ipv4.dns 8.8.4.4

The final step is to refresh the connection to make the new settings active:

nmcli connection up "<your connection name>"

With ifupdown (i.e. with network settings in /etc/network/interfaces[.d] only)

This is the default method for minimal installations.

In this case, you have to configure the actual DHCP client utility to do the substitution. Usually in this case in Debian 12 or earlier, the DHCP client is dhclient and its configuration is at /etc/dhcp/dhclient.conf.

Add a line like this to /etc/dhcp/dhclient.conf to override the DHCP-assigned DNS servers with custom ones:

supersede domain-name-servers 8.8.8.8, 8.8.4.4;

To make the setting take effect, disable & re-enable your network connection using ifdown & ifup. Obviously it's best to be locally logged-in to the server when doing this, but specifying both commands on the same command line should work even over a SSH connection if there are no errors in configuration. For example, if your network interface is named eno1 and you're running as root:

ifdown eno1; ifup eno1

Debian 13

In a minimal installation of Debian 13, there is ifupdown, no NetworkManager, and the default DHCP client has been switched from dhclient to dhcpcd. To stop it from receiving DNS server addresses from DHCP, add the line

nohook resolv.conf

to its configuration file /etc/dhcpcd.conf. Then refresh the active configuration by disabling & re-enabling the interface, e.g. for interface eno1:

ifdown eno1; ifup eno1

After that, dhcpcd (or rather its hook script component /usr/lib/dhcpcd-hooks/20-resolv.conf) will no longer touch /etc/resolv.conf and you can add your preferred DNS server settings to it the classic way. For example:

echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf

Other possibilities

Although the above might be the most common ways to handle network configurations in modern Debian, those are by no means the only possible options; for example, you might install an optional netplan, replace the default dhclient/dhcpcd DHCP client utility with something else, or even replace the whole thing with your own custom shell scripts if you had a reason to do so.

But the two variations listed above are probably the most common ones: NetworkManager is likely if the server has a desktop environment installed, and if you started with a minimal text-console installation, then you probably have the classic ifupdown.

10
  • thank you, adding supersede dns... to that file worked for me! (nmcli i dont have installed) Commented Mar 22 at 19:35
  • If you don't have nmcli, then it confirms you don't have NetworkManager installed: in Debian and related distributions (such as Pi OS) nmcli comes packaged together with the NetworkManager service. Commented Mar 23 at 13:16
  • no longer works with debian 13 :( Commented Aug 17 at 0:36
  • Have you tried setting the resolv.conf manually? Commented Aug 17 at 15:08
  • If you're using systemd-networkd you might try setting your DNS in the network configuration file like this: (just add that line according to this template, ideally after DHCP, in the [Network] part ) DNS=8.8.8.8 8.8.4.4 Commented Aug 17 at 15:17

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.