Back to articles
AI & Cloud

Configuring Unbound as an Independent DNS Resolver on VPS: Maximizing Internet Privacy

A detailed guide on setting up Unbound as an independent DNS resolver on a VPS to protect privacy, prevent tracking, and improve internet access performance. The guide covers...

DPTCloud Engineering4 min read
Configuring Unbound as an Independent DNS Resolver on VPS: Maximizing Internet Privacy

Introduction

In the digital age, internet privacy has become increasingly important. Using public DNS services like Google DNS or Cloudflare DNS may expose browsing activity to tracking or data retention. An effective solution is to self-host an independent DNS resolver on a VPS using Unbound. Unbound is an open-source, high-performance DNS resolver that supports advanced security features such as DNSSEC, DoH, and DoT.

Prerequisites and Preparation

To follow this guide, you will need:

  • A VPS (High-RAM Cloud VPS for Self-Hosted LLMs & API Gateways)
  • Linux operating system (Ubuntu 22.04 or Debian 11)
  • Stable internet connection
  • Root or sudo user privileges

Installing and Configuring Unbound

Unbound can be easily installed via the package manager.

sudo apt update
sudo apt install unbound -y

After installation, edit the main configuration file at /etc/unbound/unbound.conf:

server:
    # Bind to localhost only
    interface: 127.0.0.1
    port: 53
    do-ip4: yes
    do-ip6: no
    do-udp: yes
    do-tcp: yes

    # Enable DNSSEC validation
    dnssec: yes
    val-clean-additional: yes

    # Disable forwarding to public DNS
    forward-zone:
        name: "."
        forward-addr: 1.1.1.1@853
        forward-addr: 8.8.8.8@853

    # Cache settings
    cache-min-ttl: 3600
    cache-max-ttl: 86400
    msg-cache-size: 10m
    rrset-cache-size: 10m

    # Logging
    verbosity: 1
    log-queries: yes
    log-replies: yes

Notes:

  • Restrict Unbound to listen only on localhost (127.0.0.1) to prevent external access.
  • Do not use forwarding to public DNS if you want full control over DNS resolution.
  • Set appropriate cache values to improve performance.

Testing and Optimization

After configuration, restart Unbound and check its status:

sudo systemctl restart unbound
sudo systemctl status unbound

To verify Unbound is working correctly, use the following command:

dig @127.0.0.1 google.com

Check the logs for any errors:

sudo journalctl -u unbound -n 50 --no-pager

To optimize performance, consider the following:

  • Set num-threads: 4 if your VPS has multiple CPU cores.
  • Add prefetch: yes to speed up queries.
  • Set so-rcvbuf: 1m and so-sndbuf: 1m to optimize network buffers.

Privacy Protection Solution

By using Unbound as an independent DNS resolver, you can:

  • Prevent public DNS providers from tracking your internet browsing activity.
  • Enforce DNSSEC to ensure DNS record authenticity.
  • Use DoH (DNS over HTTPS) or DoT (DNS over TLS) if needed for encrypted DNS queries.
  • Optimize access performance by managing DNS caching locally.

This solution is ideal for enterprises seeking full control over their DNS infrastructure and user data privacy.

Troubleshooting

If Unbound fails to start, check:

  • Syntax errors in the configuration file (use unbound-checkconf).
  • Port 53 being used by another service.
  • Firewall blocking port 53.

To view processed DNS queries:

sudo unbound-control stats

These commands are useful for monitoring Unbound performance.

References

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478