This article will describe installing BIND and running DNS server for private network.
Table of Contents
1 Install BIND
Install bind package.
$ sudo pacman -Sy --noconfirm bind
2 Configuration
- Private network address is 192.168.11.0/24.
- Private network name is hiroom2.com.
- IP address of DNS server for private network is 192.168.11.79. This DNS server uses recursive query.
- IP address of client machine is 192.168.11.87.
- IP address of DNS server for internet is 192.168.11.1.
2.1 /etc/named.conf
This is the configration file for BIND.
- Allow query from private network.
- Allow recursive query.
options { directory "/var/named"; pid-file "/run/named/named.pid"; listen-on { 127.0.0.1; 192.168.11.0/24; }; recursion yes; allow-recursion { 127.0.0.1/32; 192.168.11.0/24; }; forwarders { 192.168.11.1; }; }; zone "hiroom2.com" IN { type master; file "hiroom2.com.zone"; };
2.2 /var/named/hiroom2.com.zone
This is a zone file for private network.
- DNS server hostname is server.
- Client hostname is client.
- If you need more, append A record.
$TTL 86400 @ IN SOA hiroom2.com root.hiroom2.com ( 2017062705 3600 900 604800 86400 ) @ IN NS server server IN A 192.168.11.79 client IN A 192.168.11.87
3 Validation
named-checkconf validates /etc/named.conf and included files.
$ sudo named-checkconf
named-checkzone validates zone file.
$ sudo named-checkzone hiroom2.com /var/named/hiroom2.com.zone zone hiroom2.com/IN: loaded serial 2017062705 OK
4 Run BIND
Run BIND.
$ sudo systemctl enable named $ sudo systemctl restart named
5 Excution result
Run the following on client.
Make /etc/resolv.conf to refer DNS server.
$ cat /etc/resolv.conf search hiroom2.com nameserver 192.168.11.79
DNS server returns FQDN in private network.
$ ping -c 4 server.hiroom2.com PING server.hiroom2.com (192.168.11.79) 56(84) bytes of data. 64 bytes from 192.168.11.79 (192.168.11.79): icmp_seq=1 ttl=64 time=0.024 ms 64 bytes from 192.168.11.79 (192.168.11.79): icmp_seq=2 ttl=64 time=0.041 ms 64 bytes from 192.168.11.79 (192.168.11.79): icmp_seq=3 ttl=64 time=0.041 ms 64 bytes from 192.168.11.79 (192.168.11.79): icmp_seq=4 ttl=64 time=0.043 ms --- server.hiroom2.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3057ms rtt min/avg/max/mdev = 0.024/0.037/0.043/0.008 ms
DNS server returns FQDN in internet with recursive query.
$ ping -c 4 google.co.jp <snip> --- google.co.jp ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 6.897/7.103/7.386/0.190 ms