How to Change DNS On Debian 12?

Debian 12 primarily uses systemd-resolved to manage DNS settings. This is the most reliable way to change your DNS servers.

Here are the steps:

1. Open the Terminal

  • Access your command line interface.

2. Edit the resolved.conf File

  • Type the following command and press Enter:
su
nano /etc/resolved.conf

3. Specify Your DNS Servers

  • Inside the file, look for the [Resolve] section.
  • Find the lines that start with #DNS= and #FallbackDNS=.
  • Uncomment these lines (remove the # symbol at the beginning).
  • Enter the IP addresses of your desired DNS servers, separated by spaces.

Example:

27.50.20.21 (moratel)

8.8.8.8, 8.8.4.4 (google)

4. Save and Exit the File

  • If you’re using nano:
    • Press Ctrl + O (to Write Out / Save).
    • Press Enter to confirm the filename.
    • Press Ctrl + X (to Exit).

5. Test ping to Domain From your terminal