CentOS 7.x deployment of master and slave DNS servers

CentOS 7.x deployment of master and slave DNS servers

1. Preparation

Example: Two machines: 192.168.219.146 (master), 192.168.219.147 (slave), domain name www.panyangduola.com

Both the master and slave DNS servers need to install bind, bind-chroot, and 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.219.146) configuration

Editing the Configuration File

vim /etc/named.conf

Find two of the lines

listen-on port 53 { 127.0.0.1; };
allow-query { localhost; };

Modified to

listen-on port 53 { any; };
allow-query { any; };

2-1. Configure forward parsing

Edit the file /etc/named.rfc1912.zones and add the domain to be resolved at the end

vim /etc/named.rfc1912.zones
zone "panyangduola.com" IN {
  type master;
  file "data/panyangduola.com.zone";
};

Create panyangduola.com.zone resolution domain

vim /var/named/data/panyangduola.com.zone
$TTL 3600
$ORIGIN panyangduola.com.
@ IN SOA panyangduola.com. admin.panyangduola.com. (
  2018042101
  1D
  1H
  1W
  3H
)
@ IN NS ns1.panyangduola.com.
@ IN NS ns2.panyangduola.com.
ns1 IN A 192.168.219.146
ns2 IN A 192.168.219.147
www IN A 192.168.219.146
web IN CNAME www

2-2. Configure reverse resolution

Edit the file /etc/named.rfc1912.zones and add the domain to be resolved at the end

vim /etc/named.rfc1912.zones
zone "219.168.192.in-addr.arpa" IN {
   type master;
   file "data/219.168.192.zone"; 
};

Create 219.168.192.zone resolution domain

vim /var/named/data/219.168.192.zone
$TTL 3600
$ORIGIN 219.168.192.in-addr.arpa.
@ IN SOA panyangduola.com. admin.panyangduola.com. (
  2018042101
  1D
  1H
  1W
  3H
)
@ IN NS ns1.panyangduola.com.
@ IN NS ns2.panyangduola.com.
146 IN PTR ns1.panyangduola.com.
147 IN PTR ns2.panyangduola.com.
146 IN PTR www.panyangduola.com.

2-3. Perform a syntax check on the DNS configuration file:

cd /etc
named-checkconf named.conf
named-checkconf named.rfc1912.zones
cd /var/named/data
named-checkzone panyangduola.com panyangduola.com.zone
named-checkzone 219.168.192.in-addr.arpa 219.168.192.zone

2-4. Edit /etc/resolv.conf and add

vim /etc/resolv.conf
search localdomain
nameserver 192.168.219.146

2-5. If no error occurs in step 2-3, start the named service

Restart named

systemctl restart named

View Status

systemctl status named

2-6. Check whether the primary DNS server resolution is successful

Ping command verification

ping -c 4 www.panyangduola.com
nslookup command verification nslookup
>www.panyangduola.com
nslookup
>192.168.219.146

3. Configure from DNS server (192.168.219.147)

Edit named.conf File

vim /etc/named.conf

Find two of the lines

listen-on port 53 { 127.0.0.1; }; 
  allow-query { localhost; };

Modified to

listen-on port 53 { any; };
allow-query { any; };

3-1. Modify the configuration of the primary DNS server (192.168.219.146) /etc/named.rfc1912.zones

vim /etc/named.rfc1912.zones
zone "panyangduola.com" IN {
  type master;
  file "data/panyangduola.com.zone";
  allow-transfer {192.168.219.147;};
  notify yes;
  also-notify {192.168.219.147;};
};
zone "219.168.192.in-addr.arpa" IN {
  type master;
  file "data/219.168.192.zone";
  allow-transfer {192.168.219.147;}; 
  notify yes; 
  also-notify {192.168.219.147;}; 
};

3-2. Configure forward resolution from the DNS server (192.168.219.147)

Edit the file /etc/named.rfc1912.zones and add the domain to be resolved at the end

vim /etc/named.rfc1912.zones
zone "panyangduola.com" IN {
  type slave;
  file "data/panyangduola.com.zone";
  masters { 192.168.219.146; };
};

Create an empty file for panyangduola.com.zone

touch /var/named/data/panyangduola.com.zone

Set Owner

cd /var/named/data
chown named:named panyangduola.com.zone

3-3. Configure reverse resolution from the DNS server (192.168.219.147)

Add in the file /etc/named.rfc1912.zones

vim etc/named.rfc1912.zones
zone "219.168.192.in-addr.arpa" IN {
 type slave;
 file "data/219.168.192.zone";
 masters { 192.168.219.146; }; 
  };

Create an empty file 219.168.192.zone

touch /var/named/data/219.168.192.zone

Set Owner

cd /var/named/data
chown named:named 219.168.192.zone

3-4. Perform a syntax check on the DNS configuration file:

cd /etc
named-checkconf named.conf
named-checkconf named.rfc1912.zones

3-5. Edit /etc/resolv.conf and add

vim /etc/resolv.conf
search localdomain
nameserver 192.168.219.147

3-6. If no error occurs in step 3-4, start the named service

Restart named

systemctl restart named

View Status

systemctl status named

3-7. Check whether the files /var/named/data/panyangduola.com.zone and /var/named/data/219.168.192.zone contain binary data

cat /var/named/data/panyangduola.com.zone
cat /var/named/data/219.168.192.zone

3-8. Check whether the resolution from the DNS server is successful

Ping command verification ping -c 4 www.panyangduola.com
nslookup command verification nslookup
>192.168.219.147

Summarize

The above is what I introduced to you about the deployment of master and slave DNS servers in centos7.x. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Tutorial on building a master-slave DNS server in Centos7
  • How to configure DNS server under CentOS 6.5 (with pictures and text)
  • Introduction to building a DNS server under centos7

<<:  Detailed explanation of Strict mode in JavaScript

>>:  MySQL max_allowed_packet setting

Recommend

Access the MySQL database by entering the DOS window through cmd under Windows

1. Press win + R and type cmd to enter the DOS wi...

How webpack implements static resource caching

Table of contents introduction Distinguish betwee...

Singleton design pattern in JavaScript

Table of contents 1. What is a design pattern? 2....

Steps to customize icon in Vue

ant-design-vue customizes the use of Ali iconfont...

Eight implementation solutions for cross-domain js front-end

Table of contents 1. jsonp cross-domain 2. docume...

Comparative Analysis of MySQL Binlog Log Processing Tools

Table of contents Canal Maxwell Databus Alibaba C...

JavaScript to implement the countdown for sending SMS

This article shares the specific code of JavaScri...

How to quickly add columns in MySQL 8.0

Preface: I heard a long time ago that MySQL 8.0 s...

N ways to achieve two-column layout with CSS

1. What is a two-column layout? There are two typ...

Detailed installation and configuration tutorial of PostgreSQL 11 under CentOS7

1. Official website address The official website ...

Detailed explanation of the solution for migrating antd+react projects to vite

Antd+react+webpack is often the standard combinat...

MySQL Series II Multi-Instance Configuration

Tutorial Series MySQL series: Basic concepts of M...

Analysis of the event loop mechanism of js

Preface As we all know, JavaScript is single-thre...

How to install PostgreSQL11 on CentOS7

Install PostgreSQL 11 on CentOS 7 PostgreSQL: The...

js returns to the previous page and refreshes the code

1. Javascript returns to the previous page history...