OpenSUSE Leap 15: 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 zypper -n in bind
> sudo systemctl enable named
> 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

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

> cat <<EOF | sudo tee /var/lib/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.76
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

Check if DNS server is specified in /etc/resolv.conf.

> cat /etc/resolv.conf
<snip>
search hiroom2.com
nameserver 192.168.11.76
nameserver 192.168.11.1

Run ping command to "server".

> ping -c 1 server.hiroom2.com
PING server.hiroom2.com (192.168.11.76) 56(84) bytes of data.
64 bytes from 192.168.11.76: 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