Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security, Veeam & DevOps

  • Home
  • About
  • Advertise With US
  • Reviews
  • Tech News
  • Contact
  • Toggle search form

How to setup a cache-only DNS server

Posted on 15/11/202030/08/2026 IT Expert By IT Expert No Comments on How to setup a cache-only DNS server
  1. Home
  2. Linux
  3. How to setup a cache-only DNS server
setup cache-only DNS server

A cache-only dns server (also known as a resolver) queries for information from other servers and stores the result of such queries in a memory cache for future use. Please see Azure Application Gateway: Practical Configuration Guide, and Azure Arc for SQL Server PAYG: Installation, Connectivity Requirements and Operational Best Practices.

This is a useful exercise in the event of repeating a request for a second time; a second (& similar) query will return a result in a shorter time when compared to the time the result was returned for the first query.

SETUP

1: Install the bind package: If it hasn’t been previously installed, use the following command to install the bind package:

yum install bind bind-utils -y
Terminal screenshot showing the command 'yum install bind-bind-utils -y' with output regarding plugins and loading mirror speeds.
Terminal output showing a successful installation of the BIND package on a CentOS system.

2. Edit the named.conf file

The configuration file is by default called named.conf and it is located in the etc directory. Open this file with a text editor and make the following changes;

listen-on port 53 {127.0.0.1; any;};
allow-query {localhost; any;};
allow-query-cache {localhost; any;};
recursion yes;

The next two images are the default configuration file and the edited configuration file. Make the necessary adjustment as indicated by the marked part of the images.

Ensure you have the correct port number as this will be used in altering the firewall to allow traffic through.

configure cache-only DNS,
cache-only DNS setup

Save and quit the editor.

3. Confirm file ownership

Ensure that the file ownership for named.conf is still root:named. You can use the following command to view the ownership:

ls –lZ /etc/named.conf
DNS server configuration

If for whatever reason the ownership has changed, use the chown command to make the ownership root:named.

If the server is enabled by selinux, you will need to ensure you have the right selinux context. Just to be on the safe side, run the chcon command as ssen in the image below.

setup cache-only DNS server
  • 4. Test the configuration
    After making the above configurations, test the configuration to ensure you have the right settings. If the settings are right the checkconf command should retun no result. The checkconf command is; named-checkconf /etc/named.conf
configure cache-only DNS

5. Restart and enable
Restart the named service and it to ensure it is persistent across reboot. You can also check the status of the named service.

cache-only DNS setup
Terminal output showing the status of the named service, indicating it is active and running, along with log messages about network resolution issues.

6. Edit the firewall configuration

Furthermore, Edit the firewall configuration to allow the stated port through the firewall. Then reload the firewall afterward

Terminal output showing commands to add and reload firewall ports for UDP traffic on port 53

7. Test the setup

However, Use the dig command to test the setup. The dig command is used as follows;

   dig active-web-address

 The command to test my setup will look like; dig facebook.com

Terminal output displaying the results of a DNS query for facebook.com using the dig command, showing query time of 43 ms.

Moreover, The above image is the result of the first query. Note the query time; compare it with the query time for the second query, which is the image below.

Command line interface showing a DNS query result for facebook.com, displaying the query time of 4 msec and server details.

SETTING UP A CLIENT SIDE
You can also latch on to the cache-only dns server from a client machine such that the client machine can also have a cache service when running queries.

Open up the ifcfg file on the client machine as follows;

vi /etc/sysconfig/network-scripts/ifcfg-ens33

The network interface I am using is ens33; remember to alter the command to accommodate the interface on your machine

Make the following changes to this file;

DNS1=ip-address-of-dns-server
IPPADDR=ip-address-of-client-machine
GATEWAY=network-gateway
Configuration file for Ethernet connection showing various settings such as IP version, DNS, and gateway.

Now restart the network service on the client machine and run the dig command on an active website. Then run the command again; note the query times for both command

Terminal output showing a DNS query for facebook.com with a response time of 40 milliseconds.
Command line output from the 'dig' tool displaying DNS query results for facebook.com, including query time and server information.

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Threads (Opens in new window) Threads
  • Share on Nextdoor (Opens in new window) Nextdoor
Linux Tags:DNS

Post navigation

Previous Post: How to enable or disable automatic software updates on Mac
Next Post: How to disable RC4 Cipher Algorithms support in SSH Server

Related Posts

  • feature image
    How to Configure Advanced PAM in Linux Linux
  • Header image
    How to setup a Third-Party DNS Server on a Linux Server Linux
  • linuxnethero
    Adding a subnetwork interface to an existing network interface Linux
  • MM
    How to install Mattermost on Ubuntu and Debian Linux
  • Webp.net resizeimage 1
    Automate Infrastructure Deployments in the Cloud with Ansible and Azure Pipelines AWS/Azure/OpenShift
  • Slide2 1
    SU Authentication Fix: Sudo Permission Denied in Ubuntu Linux

More Related Articles

feature image How to Configure Advanced PAM in Linux Linux
Header image How to setup a Third-Party DNS Server on a Linux Server Linux
linuxnethero Adding a subnetwork interface to an existing network interface Linux
MM How to install Mattermost on Ubuntu and Debian Linux
Webp.net resizeimage 1 Automate Infrastructure Deployments in the Cloud with Ansible and Azure Pipelines AWS/Azure/OpenShift
Slide2 1 SU Authentication Fix: Sudo Permission Denied in Ubuntu Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

Veeam Vanguard

  • windows 10 s splash 100720578 large
    Open the location of a Program: How to search in Windows 10 to find a file, folder, or program in File Explorer Windows
  • WMi tools WMI Explorer
    Query and display Windows information via WMI Explorer Network | Monitoring
  • ycx
    Install SysInternals from the Microsoft Store Windows
  • dfg
    802.1x and EAP Authentication Types Security | Vulnerability Scans and Assessment
  • ansible vault
    Fix AttributeError ‘ShellModule’ Object Has No Attribute ‘ECHO’ Configuration Management Tool
  • screenshot 2020 03 21 at 22.44.04 1
    How to create a Microsoft HyperV checkpoint Virtualization
  • veeam vulnerability backups
    Fix critical Veeam Backup and Replication 9.5, 10, and 11 vulnerabilities Backup
  • images 2
    How to disable power plan in Windows via GPO and Windows Settings Windows

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,762 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

Active Directory Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2026 TechDirectArchive

Loading Comments...

You must be logged in to post a comment.