Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Contact
  • Reviews
  • Toggle search form
Home » Linux » How to setup a cache-only DNS server
  • discorddd
    Discord Installation Guide for Linux System Linux
  • docker desktop 1
    Failed to remove network for build: Error during connect in the default daemon configuration on Windows, the Docker client must be run with elevated privileges Containers
  • Slide2
    How to Setup Jenkins Pipelines Environment for Docker Container Deployment Containers
  • onedrived43
    How to share Files and Restore Previous versions of Files in Microsoft OneDrive Backup
  • dns records
    What are the different types of DNS Records Windows Server
  • MSSQL Always On Cluster on Azure
    [AZURE] Procedure for creating an MSSQL Always On Cluster on Azure AWS/Azure/OpenShift
  • mendeley
    Install Mendeley Reference Manager: How to integrate Mendeley Cite for Microsoft Word on Mac JIRA|Confluence|Apps
  • fghj
    MDT deployment failed and Stuck at Command Prompt: Windows installation does not proceed via PXE boot Windows Server

How to setup a cache-only DNS server

Posted on 15/11/202010/09/2023 Christian By Christian No Comments on 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. 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

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

6. Edit the firewall configuration


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

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

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.

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

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

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session. I welcome you to follow me on Twitter and Facebook.

Rate this post

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

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to 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

  • Screenshot 2022 02 25 at 02.06.20
    How to install SAMBA file shares for Servers and Clients Linux
  • unionfsfeature
    How to Overlay two files with UnionFs in a Linux System Linux
  • ssh
    How to disable RC4 Cipher Algorithms support in SSH Server Linux
  • FEATURE IMAGE BASE URL 1
    How to solve cannot find a valid base URL for repo: base/7/x86_64 Linux
  • Screenshot 2022 03 15 at 10.05.53
    VMware Workstation states: What are the differences between Suspend, Power Off, and Run in Background Linux
  • feature linux boot process
    Linux Boot Process Explained Step by Step for Beginners Linux

More Related Articles

Screenshot 2022 02 25 at 02.06.20 How to install SAMBA file shares for Servers and Clients Linux
unionfsfeature How to Overlay two files with UnionFs in a Linux System Linux
ssh How to disable RC4 Cipher Algorithms support in SSH Server Linux
FEATURE IMAGE BASE URL 1 How to solve cannot find a valid base URL for repo: base/7/x86_64 Linux
Screenshot 2022 03 15 at 10.05.53 VMware Workstation states: What are the differences between Suspend, Power Off, and Run in Background Linux
feature linux boot process Linux Boot Process Explained Step by Step for Beginners 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

sysadmin top30a

  • discorddd
    Discord Installation Guide for Linux System Linux
  • docker desktop 1
    Failed to remove network for build: Error during connect in the default daemon configuration on Windows, the Docker client must be run with elevated privileges Containers
  • Slide2
    How to Setup Jenkins Pipelines Environment for Docker Container Deployment Containers
  • onedrived43
    How to share Files and Restore Previous versions of Files in Microsoft OneDrive Backup
  • dns records
    What are the different types of DNS Records Windows Server
  • MSSQL Always On Cluster on Azure
    [AZURE] Procedure for creating an MSSQL Always On Cluster on Azure AWS/Azure/OpenShift
  • mendeley
    Install Mendeley Reference Manager: How to integrate Mendeley Cite for Microsoft Word on Mac JIRA|Confluence|Apps
  • fghj
    MDT deployment failed and Stuck at Command Prompt: Windows installation does not proceed via PXE boot Windows Server

Subscribe to Blog via Email

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

Join 1,841 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

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

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.