Fedora 28: Install bind for DNS server

This article will describe installing bind and running DNS server for private network.

1 Install bind

Install bind and enable named.

$ sudo dnf install -y bind
$ sudo systemctl enable named

Open port for bind.

$ sudo firewall-cmd --add-service=dns --permanent
$ sudo firewall-cmd --reload

2 Configuration

Make /etc/named.conf to load zone file of private network.

$ cat <<EOF | sudo tee -a /etc/named.conf
zone "hiroom2.com" in {
    type master;
    file "hiroom2.com.zone";
};
EOF

Allow query from 192.168.11.0/24.

$ sudo sed \
-e "s:allow-query.*:allow-query { ${ALLOW_QUERY}; localhost; };:g" \
-e "s:listen-on port.*:listen-on port 53 { ${ALLOW_QUERY};127.0.0.1; };:g" \
-i /etc/named.conf

Create zone file of private network. Append "A record" for hostname.

$ cat <<EOF | sudo tee /var/named/hiroom2.com.zone
\$TTL 86400

@ IN SOA hiroom2.com root.hiroom2.com (
  2017010302
  3600
  900
  604800
  86400
)

@      IN NS server
server IN A  192.168.11.79
EOF

Restart bind.

$ sudo systemctl restart named

2.1 Validation

named-checkconf validates /etc/named.conf.

$ named-checkconf

named-checkzone validates zone file.

$ named-checkzone hiroom2.com /var/lib/named/hiroom2.com.zone
zone hiroom2.com/IN: loaded serial 2017010302
OK

3 Execution result

The client has the following /etc/resolv.conf. "192.168.11.79" is IP address of bind installed server.

$ cat /etc/resolv.conf
<snip>
search hiroom2.com
nameserver 192.168.11.79

Run ping command to "server".

$ ping -c 1 server.hiroom2.com
PING server.hiroom2.com (192.168.11.79) 56(84) bytes of data.
64 bytes from 192.168.11.79: icmp_seq=1 ttl=64 time=0.224 ms

--- server.hiroom2.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.224/0.224/0.224/0.000 ms