Centos7 Tutorial for Building Master Slave DNS Server
- 2021-07-03 01:13:28
- OfStack
1. Prepare
Example: Two sets of 192.168. 11.10 (master), 192.168. 11.11 (slave), domain name www. test1.com
# Master-slave DNS Servers need to be installed bind , bind-chroot , bind-utils
yum -y install bind bind-utils bind-chroot
# If the firewall is turned on, configure the firewall and add services ( Ignore if firewall is disabled )
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload
2. Main DNS Server (192.168. 11.10) Configuration
# Edit Configuration File
vim /etc/named.conf
# Find two of the lines
listen-on port 53 { 127.0.0.1; };
allow-query { localhost; };
# Modify to
listen-on port 53 { any; };
allow-query { any; };
3. Configure forward parsing
# Edit a file /etc/named.rfc1912.zones At the end, add the field to be resolved
zone "test1.com" IN {
type master;
file "data/test1.com.zone";
};
# Create test1.com.zone Analytic domain
vim /var/named/data/test1.com.zone
$TTL 3H
@ IN SOA test1.com. root (
20180928 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS @
IN A 192.168.11.10
www IN A 192.168.11.10
ftp IN A 192.168.11.10
# Edit /etc/resolv.conf , add
search localdomain
nameserver 192.168.11.10
4. Restart the DNS server
# Restart named
systemctl restart named
# View status
systemctl status named
5. Check whether the parsing is successful
# ping Command validation
ping -c 4 www.test1.com
# The output is as follows, that is, the parsing is successful
PING www.test1.com (192.168.11.10) 56(84) bytes of data.
64 bytes from ftp.test1.com (192.168.11.10): icmp_seq=1 ttl=64 time=0.033 ms
64 bytes from ftp.test1.com (192.168.11.10): icmp_seq=2 ttl=64 time=0.058 ms
64 bytes from ftp.test1.com (192.168.11.10): icmp_seq=3 ttl=64 time=0.066 ms
64 bytes from ftp.test1.com (192.168.11.10): icmp_seq=4 ttl=64 time=0.057 ms
--- www.test1.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.033/0.053/0.066/0.014 ms
# nslookup Command validation
nslookup
>www.test1.com
# The output is as follows, that is, the parsing is successful
Server: 192.168.11.10
Address: 192.168.11.10#53
Name: www.test1.com
Address: 192.168.11.10
6. Configure reverse parsing
# Edit a file /etc/named.rfc1912.zones At the end, add
vim etc/named.rfc1912.zones
zone "11.168.192.in-addr.arpa" IN {
type master;
file "data/11.168.192.zone";
};
# Create 11.168.192.zone Analytic domain
vim /var/named/data/11.168.192.zone
$TTL 3H
@ IN SOA web3.com. root (
20180928; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS www.test1.com.
10 IN PTR www.test1.com.
10 IN PTR ftp.test1.com.
7. Restart the DNS server
# Restart named
systemctl restart named
# View status
systemctl status named
8. Check whether the parsing is successful
# ping Command validation
ping -c 4 192.168.11.10
# The output is as follows, that is, the parsing is successful
PING 192.168.11.10 (192.168.11.10) 56(84) bytes of data.
64 bytes from 192.168.11.10: icmp_seq=1 ttl=64 time=0.061 ms
64 bytes from 192.168.11.10: icmp_seq=2 ttl=64 time=0.058 ms
64 bytes from 192.168.11.10: icmp_seq=3 ttl=64 time=0.081 ms
64 bytes from 192.168.11.10: icmp_seq=4 ttl=64 time=0.060 ms
--- 192.168.11.10 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.058/0.065/0.081/0.009 ms
# nslookup Command validation
nslookup 192.168.11.10
# The output is as follows, that is, the parsing is successful
Server: 192.168.11.10
Address: 192.168.11.10#53
10.11.168.192.in-addr.arpa name = ftp.test1.com.
10.11.168.192.in-addr.arpa name = www.test1.com.
9. Configure from DNS Server (192.168. 11.11)
# Modify the master first DNS Server (192.168.11.10) Configuration of /etc/named.rfc1912.zones
vim /etc/named.rfc1912.zones
zone "test1.com" IN {
type master;
file "data/test1.com.zone";
allow-transfer {192.168.11.11;};
notify yes;
also-notify {192.168.11.11;};
};
zone "11.168.192.in-addr.arpa" IN {
type master;
file "data/11.168.192.zone";
allow-transfer {192.168.11.11;};
notify yes;
also-notify {192.168.11.11;};
};
10. Configure forward parsing from DNS server (192.168. 11.11)
# Edit named.conf Documents
vim /etc/named.conf
# Find two of the lines
listen-on port 53 { 127.0.0.1; };
allow-query { localhost; };
# Modify to
listen-on port 53 { any; };
allow-query { any; };
# Edit a file /etc/named.rfc1912.zones At the end, add the field to be resolved
vim /etc/named.rfc1912.zones
zone "test1.com" IN {
type slave;
file "data/test1.com.zone"; };
masters { 192.168.11.10; };
# Create test1.com.zonek Empty file
touch /var/named/data/test1.com.zone
# Set Owner
chown named:named test1.com.zone
# Edit /etc/resolv.conf , add
vim /etc/resolv.conf
search localdomain
nameserver 192.168.11.11
11. Restart the DNS server
# Edit Configuration File
vim /etc/named.conf
# Find two of the lines
listen-on port 53 { 127.0.0.1; };
allow-query { localhost; };
# Modify to
listen-on port 53 { any; };
allow-query { any; };
0
12. Check whether the parsing is successful
# Edit Configuration File
vim /etc/named.conf
# Find two of the lines
listen-on port 53 { 127.0.0.1; };
allow-query { localhost; };
# Modify to
listen-on port 53 { any; };
allow-query { any; };
1
13. Configure reverse parsing from DNS server (192.168. 11.11)
# Edit Configuration File
vim /etc/named.conf
# Find two of the lines
listen-on port 53 { 127.0.0.1; };
allow-query { localhost; };
# Modify to
listen-on port 53 { any; };
allow-query { any; };
2
14. Restart the DNS server
# Restart named
systemctl restart named
# View status
systemctl status named
15. Check files/var/named/data/test1.com. zone and/var/named/data/11. 168.192. zone for binary data
# Edit Configuration File
vim /etc/named.conf
# Find two of the lines
listen-on port 53 { 127.0.0.1; };
allow-query { localhost; };
# Modify to
listen-on port 53 { any; };
allow-query { any; };
4
16. Check whether the parsing is successful
# Edit Configuration File
vim /etc/named.conf
# Find two of the lines
listen-on port 53 { 127.0.0.1; };
allow-query { localhost; };
# Modify to
listen-on port 53 { any; };
allow-query { any; };
5
Summarize