Install Bind/Named/DNS on CentOS
Need a Linux DNS server in a jiffy? Look no further, here’s the basic steps to get BIND Installed. Please note that it’s called both named and bind by Linux, so you should know both names.
BIND is the software package; named (name daemon) is the server process and service name. Out of the box the CentOS package configures a caching-only resolver that answers only the local machine. Below we install it, look at that default config, and open it up to your network.
Prerequisites
- A CentOS server with a static IP address (clients will point at it).
- Root access and access to the CentOS or base yum repositories.
1) Install the packages
login as root

install via yum

yum install bind-chroot bind-utils bind
bind is the server, bind-utils gives you dig, host and nslookup for testing, and bind-chroot runs named jailed under /var/named/chroot, so a compromise of named cannot reach the rest of the filesystem. On CentOS 6 the init script mounts the normal config files into the chroot, so you still edit /etc/named.conf and /var/named.
2) Enable and start named

(as you can see to start it as a service it’s called named) so set it to start on startup, and then start the service (you have to hit enter after the Generating /etc/rndc.key: part)
chkconfig named on
service named start
The first start generates /etc/rndc.key, the shared secret rndc uses to control the running server. It can pause while it gathers entropy.
3) The configuration file
from here you would create/edit your zones from the following:

here’s a look at the config:

The important lines in the default options block:
listen-on port 53 { 127.0.0.1; };named only listens on localhost.allow-query { localhost; };only the server itself may ask questions.recursion yes;it will look up outside names on behalf of allowed clients.directory "/var/named";where zone files live.
To serve your LAN, add the server’s address and your subnet (example values):
listen-on port 53 { 127.0.0.1; 192.168.1.10; };
allow-query { localhost; 192.168.1.0/24; };
Zones you host are added as zone statements in named.conf pointing at zone files in /var/named; the internal DNS server guide walks through a full forward zone.
** PLEASE SETUP SECURELY IF YOU ARE MAKING YOUR SERVER PUBLIC!!!! **
Never leave recursion yes with allow-query { any; } on an internet-facing server: an open resolver gets abused for DNS amplification attacks. Restrict recursion to your own networks with allow-recursion.
4) Check and reload
named-checkconf /etc/named.conf
service named restart
iptables -I INPUT -p udp --dport 53 -j ACCEPT
iptables -I INPUT -p tcp --dport 53 -j ACCEPT
service iptables save
named-checkconf prints nothing when the file is valid. For zone files use named-checkzone example.local /var/named/example.local.zone.
Verify
dig @127.0.0.1 www.google.com
dig @192.168.1.10 www.google.com # from another machine on the LAN
Look for status: NOERROR and an ANSWER section. A second run of the same query should come back in a few milliseconds because it is now cached.
Troubleshooting
- status: REFUSED: the client is not in allow-query (or allow-recursion).
- Connection timed out from other hosts: named is still listening only on 127.0.0.1, or the firewall blocks port 53. Check with
netstat -tulnp | grep :53. - named fails to start: run named-checkconf and read
/var/log/messages. - SERVFAIL for every outside name: often DNSSEC validation failing because the server’s clock is wrong. Fix time with NTP.
RHEL, AlmaLinux and Rocky 9/10
dnf install bind bind-utils
systemctl enable --now named
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload
The chroot is a separate unit there: install bind-chroot and enable named-chroot instead of named (not both). The dnssec-lookaside auto; line in the old default config above is obsolete. The ISC DLV registry was shut down in 2017 and current BIND releases treat the option as obsolete, so leave it out of new configs.
that’s it!
to get hosted DNS service visit www.zwiegnet.com/go to get started today!
Related guides: Configure Internal DNS Server CentOS,Redhat Linux | nsupdate cheat sheet

1 Comment