Configuring DNS nameservers on Linux Machine
Introduction
This guide explains the process of configuring dns nameserver for Linux machines running Debian 12. There are several daemons/services which manage the resolv.conf file. The resolv.conf file is where a list of nameserver IP's are kept. This file can be edited manually however will can be overwritten by a service that is supposed to manage the file on our behalf. This guide assumes that network manager is disabled, as this is preferred with Debian servers.
HOW TO
Several services will attempt to take control of the resolv.conf file, and will overwrite manual entries. These services are NetworkManager, systemd-resolved, resolvconf. If only manual entries want to be used then then ensure these three services are disabled, that is they are installed at all. Networking.service can also edit this file on boot, ensure there are no nameserver configurations in the file /etc/network/interfaces. The install of Debian 12 does not include resolvconf or systemd-resolved. Therefore manually configuring the nameserver in resolv.conf is the best option on a fresh installation.
Resolvconf can be installed to managed the resolv.conf file. Once installed and enabled the configuration for nameservers is added to /etc/resolvconf/resolv.conf.d/head. Once any changes have been made use the command sudo resolvconf -u to enable the updated configuration. A change in the file /etc/resolv.conf should be seen.