Introduction to DNS: the whole process of BIND installation and configuration
I. Download BIND
The version downloaded for this experiment is: BIND 9.11.0-P2
II. Installation of BIND
1. Enter the directory of the compressed package, decompress it, and enter the bind directory.
[root@TEST opt]# tar zxvf bind-9.11.0-P2.tar.gz
[root@TEST opt]# cd bind-9.11.0-P
2. Compile configuration
[root@TEST bind-9.11.0-P2]# ./ configure --prefix=/data/sdns/named --enable-threads #--enable-threads Enable multithreading
[root@TEST bind-9.11.0-P2]#make
[root@TEST bind-9.11.0-P2]#make install
3. Create a configuration file
[root@TEST named]# cd /data/sdns/named
4. Generate key file of rndc control command
[root@TEST named]# sbin/rndc-confgen > etc/rndc.conf
5. Extract the key for named.conf from rndc.conf
[root@TEST named]#tail -10 etc/rndc.conf | head -9 | sed s/#\ //g > etc/named.conf
6. Configure named.conf
[root@TEST named]#vim /data/sdns/named/etc/named.conf
increase
options {
directory "/data/sdns/zone/";
pid-file "named.pid";
};
zone ". " IN {
type hint;
file "named.root";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "test.com" IN {
type master;
file "test.zone";
allow-update { none; };
};
7. Create a zone directory file
[root@TEST named]#mkdir /data/sdns/zone
[root@TEST named]#cd /data/sdns/zone
Create localhost.zone file
[root@TEST named]#vim localhost.zone
increase
$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS @
1D IN A 127.0.0.1
B. Create named.local file
[root@TEST named]#vim named.local
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
C. Create test.zone file
[root@TEST named]#vim test.zone
increase
$ttl 1D
@ IN SOA test.com. root.test.com. (
1053891162
3H
15M
1W
1D )
IN NS ns.test.com.
IN MX 5 test.com.
IN A 3.3.3.3
ns IN A 1.2.3.4
www IN A 220.202.19.82
D. dig command directly generates named.root file
[root@TEST named]#dig > named.root
8. Start bind
[root@TEST named]#/data/sdns/named/sbin/named -c /data/sdns/named/etc/named.conf &
9, reload the configuration file (common command, modify the configuration file, you can use this command to update)
[root@TEST named]#/data/sdns/named/sbin/rndc reload
10. Testing
[root@TEST named]#dig @127.0.0.1 test.com