BIND: Install
BIND: Install
Install BIND to configure DNS server which resolves domain name or IP address. DNS uses
53/TCP,UDP.
[1] Install BIND 9.
root@dlp:~# vi /etc/bind/named.conf
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
# comment out
# include "/etc/bind/named.conf.default-zones";
# add
include "/etc/bind/named.conf.internal-zones";
include "/etc/bind/named.conf.external-zones";
root@dlp:~# vi /etc/bind/named.conf.internal-zones
# create new
view "internal" {
match-clients {
localhost;
10.0.0.0/24;
};
# set zone for internal
zone "srv.world" {
type master;
file "/etc/bind/srv.world.lan";
allow-update { none; };
};
# set zone for internal *note
zone "0.0.10.in-addr.arpa" {
type master;
file "/etc/bind/0.0.10.db";
allow-update { none; };
};
include "/etc/bind/named.conf.default-zones";
};
root@dlp:~# vi /etc/bind/named.conf.external-zones
# create new
view "external" {
match-clients { any; };
# allow any query
allow-query { any; };
# prohibit recursion
recursion no;
zone "srv.world" {
type master;
file "/etc/bind/srv.world.wan";
allow-update { none; };
};
zone "80.0.16.172.in-addr.arpa" {
type master;
file "/etc/bind/80.0.16.172.db";
allow-update { none; };
};
};
# *note : For How to write for reverse resolving, Write network address reversely like below
# Case of 10.0.0.0/24
# network address ⇒ 10.0.0.0
# Case of 172.16.0.80/29
root@dlp:~#
vi /etc/bind/named.conf.options
options {
directory "/var/cache/bind";
// to talk to, you may need to fix the firewall to allow multiple
// forwarders {
// 0.0.0.0;
// };
//========================================================================
// If BIND logs error messages about the root key being expired,
//========================================================================
dnssec-validation auto;
listen-on-v6 { none; };
};
2019/07/16
Create zone files that servers resolve IP address from domain name.
[1] For internal zone,
On this example, Configure BIND with internal address [10.0.0.0/24], domain name [srv.world]. Pease replace IP add
Name to your own environment.
root@dlp:~#
vi /etc/bind/srv.world.lan
$TTL 86400
2019071601 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
IN NS dlp.srv.world.
IN A 10.0.0.30
IN MX 10 dlp.srv.world.
dlp IN A 10.0.0.30
root@dlp:~#
vi /etc/bind/srv.world.wan
$TTL 86400
2019071601 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
IN A 172.16.0.82
IN MX 10 dlp.srv.world.
dlp IN A 172.16.0.82
root@dlp:~#
vi /etc/bind/0.0.10.db
$TTL 86400
2019071601 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
IN NS dlp.srv.world.
IN PTR srv.world.
IN A 255.255.255.0
30 IN PTR dlp.srv.world.
root@dlp:~#
vi /etc/bind/80.0.16.172.db
$TTL 86400
2019071601 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
IN NS dlp.srv.world.
IN PTR srv.world.
IN A 255.255.255.248
82 IN PTR dlp.srv.world.
2019/07/16
Restart BIND to apply changes and Verify name or Address Resolution.
[1] Change DNS setting to refer to local DNS.
root@dlp:~#
systemctl restart bind9
root@dlp:~#
vi /etc/resolv.conf
domain srv.world
search srv.world
nameserver
10.0.0.30
root@dlp:~#
dig dlp.srv.world.
;; Got answer:
;; OPT PSEUDOSECTION:
;; QUESTION SECTION:
;dlp.srv.world. IN A
;; ANSWER SECTION:
;; AUTHORITY SECTION:
;; SERVER: 10.0.0.30#53(10.0.0.30)
root@dlp:~#
dig -x 10.0.0.30
;; Got answer:
;; OPT PSEUDOSECTION:
;; QUESTION SECTION:
;30.0.0.10.in-addr.arpa. IN PTR
;; ANSWER SECTION:
;; AUTHORITY SECTION:
;; ADDITIONAL SECTION:
;; SERVER: 10.0.0.30#53(10.0.0.30)
2019/07/16
If you'd like to set another name (Alias) to your Host, define CNAME record in zone file.
[1] Set CNAME record in zone file.
root@dlp:~#
vi /etc/bind/srv.world.lan
$TTL 86400
# update serial
2019071602 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
IN NS dlp.srv.world.
IN A 10.0.0.30
IN MX 10 dlp.srv.world.
dlp IN A 10.0.0.30
root@dlp:~#
rndc reload
root@dlp:~#
dig ftp.srv.world.
;; Got answer:
;; QUESTION SECTION:
;ftp.srv.world. IN A
;; ANSWER SECTION:
;; AUTHORITY SECTION:
;; SERVER: 10.0.0.30#53(10.0.0.30)
2019/07/16
Configure BIND as a Slave DNS Server.
The following example shows an environment that master DNS is [172.16.0.82], Slave DNS is
[slave.example.host].
[1] Configure DNS master server.
root@dlp:~#
vi /etc/bind/named.conf.options
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// forwarders {
// 0.0.0.0;
// };
//========================================================================
// If BIND logs error messages about the root key being expired,
//========================================================================
dnssec-validation auto;
listen-on-v6 { any; };
};
root@dlp:~#
rndc reload
root@slave:~#
vi /etc/bind/named.conf.external-zones
zone "srv.world" {
type slave;
masters { 172.16.0.82; };
file "/etc/bind/slaves/srv.world.wan";
};
root@slave:~#
mkdir /etc/bind/slaves
root@slave:~#
chown bind. /etc/bind/slaves
root@slave:~#
rndc reload
ls /etc/bind/slaves
srv.world.wan