How to install and configure caching DNS in CENTOS 7

We will install caching nameserver using sofware unbound. this is not a full DNS server. unbound will only cache the DNS from other DNS server

OS: RHEL 7
unbound version: unbound-1.4.20-28.el7.x86_64

1. Install unbound in the server
Server > yum -y install unbound

2- Start the unbound service.
Server > systemctl start unbound.service
Server > systemctl enable unbound.service

3- Here are some item that we need to adjust is the config file.
Unbound config file is stored in /etc/unbound/unbound.conf


  • interface = <listen interface ip>
  • access-control = 172.25.0.0/24 allow #allow these subnet to queries
  • domain-insecure = "example.com" #allow insecure DNSSEC validation
  • forward-zone:
    • name: .
    • forward-addr: 172.25.254.254 #the DNS server ip
4- Now, check for any syntax error
Server > unbound_checkconf

5- Restart unbound service
Server > systemctl restart unbound.service

6- Configure firewall to allow DNS
Server > firewall-cmd --permanent --add-service=dns
Server > firewall-cmd --reload

7- Verify your unbound server
Server > unbound-control dump_cache

you are now complete. if your desktop DNS pointing to the unbound server..it should be ok.

Now, we query for A record 
Desktop > dis @testserver.example.com  A desktop.example.com


How to purge unbound record from cache.
server > unbound-control flush testserver.example.com


Troubleshooting DNS problem

1- check your /etc/hosts
2- check you /etc/resolv.conf
3- use geten. eg:getent hosts example.com
4- use gethostip. eg: gethostip example.com


Comments