Name Server Guide

DNS Configuration Guide for Debian-Based Linux Systems

This guide provides step-by-step instructions for configuring custom DNS servers on Debian-based Linux distributions (Debian, Ubuntu, Linux Mint, etc.). The example uses Cloudflare DNS (1.1.1.1 and 1.0.0.1), but you can substitute with your preferred DNS servers.

Prerequisites

  • Debian-based Linux distribution
  • Root or sudo privileges
  • Basic understanding of network configuration

System Compatibility

This guide has been tested on:

  • Debian 10 (Buster) and newer
  • Ubuntu 20.04 LTS and newer

Configuration Steps

1. Check Network Interface Configuration

First, examine the primary network interface configuration:

sudo nano /etc/network/interfaces

2. Check Secondary Configuration (if needed)

If no DNS configuration exists in the primary file, check the interfaces directory:

sudo nano /etc/network/interfaces.d/50-cloud-init

Note: The 50-cloud-init configuration is common in cloud-hosted Debian instances.

3. Remove Existing DNS Configuration

In either file, locate and remove or comment out any existing DNS configuration:

# Comment out or remove lines like:
# dns-nameservers xxx.xxx.xxx.xxx

Save the changes:

  • In nano: Press Ctrl + X, then Y, then Enter

4. Configure DHCP Client

Edit the DHCP client configuration:

sudo nano /etc/dhcp/dhclient.conf

Add the following line (using Cloudflare DNS as example):

supersede domain-name-servers 1.1.1.1, 1.0.0.1;

Save the changes:

  • In nano: Press Ctrl + X, then Y, then Enter

5. Restart Networking Service

Apply the changes by restarting the networking service:

sudo systemctl restart networking

Note: On some newer Debian-based systems, you might need to use:

sudo systemctl restart NetworkManager

6. Verify Configuration

Check the current DNS configuration:

cat /etc/resolv.conf

Test DNS resolution:

sudo nslookup google.com

Expected output should show responses from your configured DNS servers.

Notes

Common Issues

  1. Network Disconnection: If you lose network connectivity after restart:
    sudo systemctl restart networking
    # or
    sudo systemctl restart NetworkManager
    
  2. DNS Not Updating: Verify dhclient is using the new configuration:
    sudo systemctl restart network-manager
    
  3. Resolution Failures: Test with multiple domains:
    nslookup cloudflare.com
    nslookup github.com
    

Security Notes

On Debian systems, consider:

  1. Setting proper file permissions
  2. Using DNS over HTTPS (DoH) if supported
  3. Configuring UFW firewall for DNS ports

Additional Resources

  • Debian Wiki Network Configuration
  • Cloudflare DNS Documentation: https://1.1.1.1/dns/
  • Ubuntu Network Configuration Guide
Remember to replace the example DNS servers (1.1.1.1, 1.0.0.1) with your preferred DNS servers if not using Cloudflare.