Centos7 tutorial to build a master-slave DNS server

1、 ready

Example: two 192.168.11.10 (master), 192.168.11.11 (slave), domain name www.test1.com

# Both master and slave DNS servers need to install bind and bind-chroot、bind-utils
yum -y install bind bind-utils bind-chroot
# If the firewall is enabled, configure the firewall and add services(Ignore if the firewall is disabled)
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload

2、 Primary DNS server (192.168.11.10) configuration

# Edit configuration file
vim /etc/named.conf
# Find two lines
  listen-on port 53{127.0.0.1;}; 
  allow-query { localhost;};
# change into
  listen-on port 53{ any;};
  allow-query   { any;};

3、 Configure forward analysis

# Edit file/etc/named.rfc1912.zones, add the domains that need to be resolved at the end
 zone "test1.com" IN {
 type master;
 file "data/test1.com.zone";};
# Create test1.com.zone resolution 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 DNS server

# Restart named
systemctl restart named
# Check status
systemctl status named

5、 Check if the analysis is successful

# ping command verification
ping -c 4 www.test1.com
# The output is as follows and the analysis 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 verification
nslookup
> www.test1.com
# The output is as follows and the analysis 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 analysis

# Edit file/etc/named.rfc1912.zones, add at the end
vim etc/named.rfc1912.zones
 zone "11.168.192.in-addr.arpa" IN {
  type master;
  file "data/11.168.192.zone";};
# Created 11.168.192.zone resolution 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 DNS server

# Restart named
systemctl restart named
# Check status
systemctl status named

8、 Check if the analysis is successful

# ping command verification
ping -c 4192.168.11.10
# The output is as follows and the analysis is successful
  PING 192.168.11.10(192.168.11.10)56(84) bytes of data.64 bytes from192.168.11.10: icmp_seq=1 ttl=64 time=0.061 ms
  64 bytes from192.168.11.10: icmp_seq=2 ttl=64 time=0.058 ms
  64 bytes from192.168.11.10: icmp_seq=3 ttl=64 time=0.081 ms
  64 bytes from192.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 verification
nslookup 192.168.11.10
# The output is as follows and the analysis is successful
  Server:192.168.11.10
  Address:192.168.11.10#5310.11.168.192.in-addr.arpa  name = ftp.test1.com.10.11.168.192.in-addr.arpa  name = www.test1.com.

9、 Configure the slave DNS server (192.168.11.11)

# Modify the primary DNS server first(192.168.11.10)Configuration/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 resolution from DNS server (192.168.11.11)

# Edit named.conf file
vim /etc/named.conf
  #Find two lines
  listen-on port 53{127.0.0.1;};   
  allow-query { localhost;};
  #change into
  listen-on port 53{ any;};
  allow-query   { any;};
# Edit file/etc/named.rfc1912.zones, add the domains that need to be resolved at the end
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 DNS server

# Restart named
systemctl restart named
# Check status
systemctl status named

12、 Check whether the analysis is successful

# ping command verification
ping -c 4 www.test1.com
# The output is as follows and the analysis 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 verification
nslookup
> www.test1.com
# The output is as follows and the analysis is successful
  Server:192.168.11.11
  Address:192.168.11.11#53
  Name:  www.test1.com
  Address:192.168.11.10

13、 Configure reverse resolution from DNS server (192.168.11.11)

# In file/etc/named.rfc1912.add in zones
vim etc/named.rfc1912.zones
 zone "11.168.192.in-addr.arpa" IN {
  type master;
  file "data/11.168.192.zone";
      masters {192.168.11.10;};};
# Create empty file 11.168.192.zone
touch /var/named/data/11.168.192.zone
# Set owner
chown named:named 11.168.192.zone

14、 Restart DNS server

# Restart named
systemctl restart named
# Check status
systemctl status named

15、 Check whether the files /var/named/data/test1.com.zone and /var/named/data/11.168.192.zone have binary data

cat /var/named/data/test1.com.zone
cat /var/named/data/11.168.192.zone

16、 Check if the analysis is successful

# ping command verification
ping -c 4192.168.11.11
# The output is as follows and the analysis is successful
  PING 192.168.11.11(192.168.11.11)56(84) bytes of data.64 bytes from192.168.11.11: icmp_seq=1 ttl=64 time=0.061 ms
  64 bytes from192.168.11.11: icmp_seq=2 ttl=64 time=0.058 ms
  64 bytes from192.168.11.11: icmp_seq=3 ttl=64 time=0.081 ms
  64 bytes from192.168.11.11: icmp_seq=4 ttl=64 time=0.060 ms
  ---192.168.11.11 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 verification
nslookup 192.168.11.11
# The output is as follows and the analysis is successful
  Server:192.168.11.11
  Address:192.168.11.11#5310.11.168.192.in-addr.arpa  name = ftp.test1.com.10.11.168.192.in-addr.arpa  name = www.test1.com.

to sum up

The above is the tutorial for setting up a master-slave DNS server for Centos7 introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!

Recommended Posts

Centos7 tutorial to build a master-slave DNS server
CentOS uses Nginx to build a download function server
Centos8 implementation steps to build a local web server
CentOS8.1 build Gitlab server detailed tutorial
(1) Centos7 installation to build a cluster environment
How to quickly build Nginx server under CentOS
Python3 development environment to build a detailed tutorial
Centos7 build DNS service
How to build a LAMP environment on centos7.2
3 minutes to teach you to build gitea on Centos server
How to set up a DNS server on Ubuntu 18.04
Use Rancher to build a K8s cluster under CentOS7
Build OpenV** Server under CentOS7
Build OpenLDAP server under CentOS7
Ubuntu16.04 build GitLab server tutorial
First try to build a Ceph storage cluster on Centos7
Teach you how to build a Git server on Ubuntu
Detailed steps to set up a Git server on CentOS
Build a PXC cluster under CentOS8
Centos6 method steps to build gitlab
Build an FTP server under centos7
Centos7 build java web server tomcat
Build a file server on ubuntu
Modify CentOS server time to Beijing time
Centos8 uses Docker to deploy a detailed tutorial for Django projects
Centos7 uses vim to build powerful pyt
[PHP] Build a PHP operating environment under CentOS
Centos8 use yum to install rabbitmq tutorial
Build a Minecraft Bedrock Edition server (Ubuntu)
How to monitor CentOS 7 server with Prometheus
Build a ScaleIO distributed storage cluster under CentOS7
Linux (CentOS7) using RPM to install mysql 8.0.11 tutorial
Build LEMP (Linux+Nginx+MySQL+PHP) environment under CentOS 8.1 (detailed tutorial)
How to modify the CentOS server time to Beijing time
Centos7.2 compile and install way to build phpMyAdmin
CentOS7 build jenkins
Centos build lnmp
Centos7 build python3.8.5+scrapy+gerapy
The tutorial for upgrading from Centos7 to Centos8 (detailed graphic)
Build a basic environment for Java development under Centos7
How to create a CentOS virtual machine in VMware
How to configure FTP server with Vsftpd on CentOS 8
Centos8 (minimal installation) a new installation of Python3.8+pip method tutorial
A simple tutorial to install Sogou Pinyin on ubuntu18.04
How to install and configure NFS server on CentOS 8
How to create a CentOS virtual machine in VMware
How to configure FTP server with Vsftpd on CentOS 8