Setting an alternative DNS server in resolv.conf

I have Pi-hole installed on Raspbian 11. My /etc/resolv.conf has a nameserver entry pointing to itself for DNS resolution. When Pi-hole hangs or is stopped, all DNS resolution on that system fails.

I would like to add a secondary DNS server to only that system, but I do not have a /etc/resolvconf/resolv.conf.d directory and adding head or tail files here and rebooting does nothing.

The Pi gets its IP and DNS server (itself) from DHCP. So far, I have managed to achieve what I need by changing my /etc/resolvconf.conf file and setting name_servers= to the entries I need.

I'm confused how all this fits together despite reading a hundred posts about resolv, dnsmasq, dhcpcd.conf and everything else. Shouldn't adding head / tail files to the system to append DNS servers work?

File /etc/resolv.conf is populated from other files. If you change the contents of the file, your changes will be overwritten next restart.

If you look at the file, you will see something like this (this Pi is running Raspbian 11), which indicates the process that populates the file:

cat /etc/resolv.conf
# Generated by dhcpcd from enxb827eb0c8c4f.dhcp
# /etc/resolv.conf.head can replace this line
nameserver 127.0.0.1

Note I changed resolvconf.conf not resolv.conf.

My resolv.conf doesn't look like yours:

pi@homebridge:~ $ cat /etc/resolv.conf
# Generated by resolvconf
search fritz.box
nameserver 192.168.1.6

Below might reveal more:

resolvconf -l

That shows different comments:

# resolv.conf from NetworkManager
# Generated by NetworkManager

And for some reason doesn't now list all of the name servers that appear in resolv.conf

NetworkManager (NM) is most likely populating resolv.conf:

pi@ph5b:~ $ apt show network-manager
[..]
Description: network management framework (daemon and userspace tools)
 NetworkManager is a system network service that manages your network devices
 and connections, attempting to keep active network connectivity when
 available. It manages ethernet, Wi-Fi, mobile broadband (WWAN), and PPPoE
 devices, and provides VPN integration with a variety of different VPN
 services.
 .
 This package provides the userspace daemons and a command line interface to
 interact with NetworkManager.
 .
 Optional dependencies:
  * ppp: Required for establishing dial-up connections (e.g. via GSM).
  * dnsmasq-base/iptables: Required for creating Ad-hoc connections and
    connection sharing.
  * libteam-utils: Network Team driver allows multiple network interfaces to be
    teamed together and act like a single one. This process is called "ethernet
    bonding", "channel teaming" or "link aggregation".

You can check which connection name is active with below:

nmcli connection show --active

And see how NM is configured for that connection name with below:

nmcli -p connection show <NAME>

It lists the wired connection I'm using and the single DNS server DHCP has told it to use.

NM most likely configured 127.0.0.1 in resolv.conf bc its expecting a stub resolver to answer on that address (for caching).
These are all distro specific related settings.
You should consult documentation for your distro for this!