🛡️ Configuring a Linux Server as a Secure DNS Resolver
Configuring a Linux server as a secure DNS resolver enhances your privacy and security by encrypting DNS queries. This tutorial will guide you through setting up a secure DNS resolver using Unbound with DNS over TLS (DoT).
Prerequisites
* A Linux server (e.g., Ubuntu, Debian, CentOS)
* Root or sudo privileges
* Basic knowledge of Linux command line
Step 1: Install Unbound
Unbound is a validating, recursive DNS resolver. Install it using your distribution's package manager.
For Debian/Ubuntu:
sudo apt update
sudo apt install unbound
For CentOS/RHEL:
sudo yum install unbound
Step 2: Configure Unbound for DNS over TLS
Create a new Unbound configuration file for DNS over TLS.
sudo nano /etc/unbound/unbound.conf.d/dns-over-tls.conf
Add the following configuration:
server:
interface: 0.0.0.0
port: 53
do-not-query-localhost: no
# Enable DNS over TLS
tls-service: yes
# Forward DNS queries to Cloudflare's DNS servers (you can use other DoT providers)
forward-zone:
name: "."
forward-addr: 1.1.1.1@853
forward-addr: 1.0.0.1@853
forward-addr: 2606:4700:4700::1111@853
forward-addr: 2606:4700:4700::1001@853
forward-tls: yes
Explanation:
*
interface: 0.0.0.0: Listens on all interfaces.
*
port: 53: Standard DNS port.
*
tls-service: yes: Enables TLS for DNS.
*
forward-addr: Specifies the DNS over TLS server and port (853).
*
forward-tls: yes: Enforces TLS for forwarded queries.
Save the file and exit.
Step 3: Test the Configuration
Before restarting Unbound, test the configuration for syntax errors:
sudo unbound-check
If there are no errors, you'll see:
unbound-check: unbound.conf is ok
Step 4: Restart Unbound
Restart the Unbound service to apply the changes:
sudo systemctl restart unbound
Verify that Unbound is running:
sudo systemctl status unbound
Step 5: Configure Clients to Use the DNS Resolver
Configure your client machines to use your Linux server's IP address as their DNS server. The method varies depending on the operating system.
Example for Linux:
Edit
/etc/resolv.conf (note: this file is often managed by NetworkManager; edit the appropriate network configuration file instead for persistent changes):
sudo nano /etc/resolv.conf
Add or modify the following lines:
nameserver your_server_ip_address
Replace
your_server_ip_address with the actual IP address of your Linux server.
Example for Windows:
1. Go to Control Panel > Network and Internet > Network and Sharing Center.
2. Click on your active network connection.
3. Click Properties.
4. Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
5. Select "Use the following DNS server addresses:"
6. Enter your Linux server's IP address as the Preferred DNS server.
Step 6: Verify DNS over TLS
You can verify that DNS over TLS is working using online tools or command-line utilities.
Using dig:
Install
dig if it's not already installed:
sudo apt install dnsutils # Debian/Ubuntu
sudo yum install bind-utils # CentOS/RHEL
Run the following command:
dig +tls sigfail.verteilt.net @your_server_ip_address
If DNS over TLS is working correctly, you should receive a valid response without errors. You can also use online DNS leak test tools to confirm that your DNS queries are going through your server and are encrypted.
Conclusion 🎉
By following these steps, you have successfully configured your Linux server as a secure DNS resolver using Unbound with DNS over TLS. This setup enhances your network's privacy and security by encrypting DNS queries and preventing eavesdropping. Remember to regularly update your system and Unbound to maintain optimal security.