DNS domain name resolves to IP address ------ set master and slave domain name server

1. Environmental installation requirements

1. Set the yum source to be permanently mounted
2. Install three virtual machines; one master domain name server; one slave domain name server; one test machine
3. The virtual and real machine firewalls are turned off, and the core protection is turned off (all three need to be turned off) )
4. BIND package installation: bind; bind-utils; bind-libs; bind-chroot

(installation command: yum -y install bind bind-utils bind-libs bind-chroot)

Environmental installation steps

1. Yum source permanent mount configuration:

虚拟机光盘勾上已连接 ;设置 mount /dev/cdrom /mnt 挂载点 ;查看挂载点:df -Th
切换至:cd  /etc/yum.repos.d/ ; 创建文件:mkdir backup ; 移动文件:mv  C*  backup/
复制文件内容至目标文件: cp  backup/CentOS-Base.repo  local.repo
编制目标文件:vi  local.repo
   命令模式下:36dd:删除其他内容,并找到以下内容,更改如下   
   [centos]
   name=CentOS            #####名称
   baseurl=file:///mnt        #####在/mnt文件下查找
   gpgcheck=0              #####0:不检验
   enabled=1               #####1:开启服务
   #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Input: yum clean all #####Clear yum cache
Input: yum makecache ###### Open local yum cache

编辑永久挂载:vi  /etc/fstab
添加:/dev/cdrom  /mnt  iso9660  defaults  0  0
   :wq

2, 3, 4. Install the virtual machine; turn off the firewall and core protection; install the yum package:

2. Virtual machine installation: configure the IP address; and restart the network card; check ifconfig

3. Turn off the firewall and core protection commands:

systemctl  status  firewalld     ######查看防火墙状态
systemctl  stop  firewalld      ######关闭防火墙
systemctl  disable  firewalld     ######开机自动关闭防火墙

Change the core protection: vi /etc/selinux/confing change this behavior disable: SELINUX=disabled

4、yum包安装 :yum -y install bind bind-utils bind-libs bind-chroot

Two, start to configure the master-slave domain name server

Global configuration:

vi  /etc/named.conf
 options {
    listen-on port 53 { 20.0.0.11; };
    listen-on-v6 port 53 { ::1; };
    forwarders { 8.8.8.8; 114.114.114.114; };
    directory       "/var/named";
    dump-file       "/var/named/data/cache_dump.db";
    statistics-file "/var/named/data/named_stats.txt";
    memstatistics-file "/var/named/data/named_mem_stats.txt";
    allow-query     { any; };

Specific DNS zone configuration:

vi  /etc/named.rfc1912.zones
添加正向解析:
zone "bdqn.com" IN {
    type master;
    file "bdqn.com.zone";
    allow-transfer { 20.0.0.12; };
    also-notify { 20.0.0.12; };
};

添加反向解析:
zone "0.0.20.in-addr.arpa" IN {
    type master;
    file "20.0.0.arpa";
    allow-transfer { 20.0.0.12; };
    also-notify { 20.0.0.12; };
};

Edit domain name: vi /var/named/bdqn.com.zone

 添加: $TTL 1D
@       IN SOA bdqn.com. admin.bdqn.com. (
                                    0       ;serial
                                    1D      ;refresh
                                    1H      ;retry
                                    1W      ;expire
                                    3H )    ;minimum
   	        NS      @
    	    A      192.168.11.119
www    IN  	A      192.168.11.119
ftp    IN 	A      192.168.11.118
mail   IN  CNAME   www

Change owner: chown named:named /var/named/bdqn.come.zone

Edit ip: vi /var/named/20.0.0.arpa

添加:$TTL 1D
@       IN SOA  bdqn.com. admin.bdqn.com.zone. (
                                    1       ;serial
                                    1D      ;refresh
                                    1H      ;retry
                                    1W      ;expire
                                    3H )    ;minimum
   		 NS     bdqn.com.
  		 A      20.0.0.100
119 IN  PTR     www.bdqn.com.
120 IN  PTR     ftp.bdqn.com.
121 IN  PTR     bbs.bdqn.com.

Change owner: chown named:named /var/named/20.0.0.arpa

Perform a grammar check: named-checkconf -z /etc/named.conf

重启named: systemctl restart named

Three, start configuration from the domain name server

Global configuration:

vi  /etc/named.conf
 options {
    listen-on port 53 { 20.0.0.12; };
    listen-on-v6 port 53 { ::1; };
    directory       "/var/named";
    dump-file       "/var/named/data/cache_dump.db";
    statistics-file "/var/named/data/named_stats.txt";
    memstatistics-file "/var/named/data/named_mem_stats.txt";
    allow-query     { any; };

Specific DNS zone configuration:

vi  /etc/named.rfc1912.zones
添加正向解析:
      zone "bdqn.com" IN {
    	   type slave;
    	   masters { 20.0.0.11; };
   		   allow-notify { 20.0.0.11; };
   		   file "slaves/bdqn.com.zone";
      };

添加反向解析:
      zone "0.0.20.in-addr.arpa" IN {
   		   type slave;
    	   masters { 20.0.0.11; };
   	   	   allow-notify { 20.0.0.11; };
   		   file "slaves/20.0.0.arpa";
      };

Check that there is no data in the file: cd /var/named/slaves/; ll command to
open named: systemctl start named
Check again that there is data in the file: ll command

Four, test machine for testing

Add mapping relationship

vi  /etc/resolv.conf
添加映射关系:#nameserver 20.0.0.11 ;谁测,另外一条添加#号
             nameserver 20.0.0.12

Test: Forward analysis

[root@localhost ~]# nslookup www.bdqn.com
Server:         20.0.0.12
Address:        20.0.0.12#53
Name:   www.bdqn.com
Address: 192.168.11.119

[root@localhost ~]# nslookup ftp.bdqn.com
Server:         20.0.0.12
Address:        20.0.0.12#53
Name:   ftp.bdqn.com
Address: 192.168.11.118

Test: reverse analysis

[root@localhost ~]# nslookup 20.0.0.119
Server:         20.0.0.12
Address:        20.0.0.12#53
119.0.0.20.in-addr.arpa name = www.bdqn.com.

[root@localhost ~]# nslookup 20.0.0.120
Server:         20.0.0.12
Address:        20.0.0.12#53
120.0.0.20.in-addr.arpa name = ftp.bdqn.com.

——————————————————————————————————————————————————————————————————————————————————————————

This concludes, thanks for watching, I hope it will be helpful to the judge

Guess you like

Origin blog.csdn.net/XCsuperman/article/details/107803440