Linux operation and maintenance --- Use Bind to provide domain name resolution services

Knowledge that can be learned after reading this article: ①Forward resolution and reverse resolution ②Deployment of DNS server

Forward resolution: Find the corresponding IP address based on the host name (domain name).

Reverse resolution: Find the corresponding host name (domain name) based on the IP address.

The DNS service protocol uses a hierarchical structure similar to a directory tree to record the mapping relationship between domain names and IP addresses to form a distributed database system: DNS structure model

Main server: It is unique in a specific area and is responsible for maintaining the correspondence between domain names and IP addresses in that area.

Slave server: Obtain and maintain the correspondence between domain names and IP addresses from the master server to prevent the master server from downtime.

Cache server: Obtain the correspondence between domain names and IP addresses by querying other domain name servers to improve the efficiency of repeated queries.

DNS query is divided into: recursive query and iterative query

Recursive query: used by the client to query the DNS server.

Iterative query: used for DNS server to query other DNS servers.

Install bind-chroot

[root@localhost ~]# yum install bind-chroot
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
mysql-connectors-community                               | 2.5 kB     00:00
mysql-tools-community                                    | 2.5 kB     00:00
mysql56-community                                        | 2.5 kB     00:00
yum                                                      | 4.1 kB     00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 bind-chroot.x86_64.32.9.9.4-29.el7 将被 安装
--> 正在处理依赖关系 bind = 32:9.9.4-29.el7,它被软件包 32:bind-chroot-9.9.4-29.el7.x86_64 需要
--> 正在检查事务
---> 软件包 bind.x86_64.32.9.9.4-29.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 Package             架构           版本                      源           大小
================================================================================
正在安装:
 bind-chroot         x86_64         32:9.9.4-29.el7           yum          83 k
为依赖而安装:
 bind                x86_64         32:9.9.4-29.el7           yum         1.8 M

事务概要
================================================================================
安装  1 软件包 (+1 依赖软件包)

总下载量:1.9 M
安装大小:4.3 M
Is this ok [y/d/N]: y
Downloading packages:
--------------------------------------------------------------------------------
总计                                                43 MB/s | 1.9 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 32:bind-9.9.4-29.el7.x86_64                                 1/2
  正在安装    : 32:bind-chroot-9.9.4-29.el7.x86_64                          2/2
  验证中      : 32:bind-9.9.4-29.el7.x86_64                                 1/2
  验证中      : 32:bind-chroot-9.9.4-29.el7.x86_64                          2/2

已安装:
  bind-chroot.x86_64 32:9.9.4-29.el7

作为依赖被安装:
  bind.x86_64 32:9.9.4-29.el7

完毕!

Main program: /usr/sbin/named

Main configuration file: /etc/named.conf

Zone configuration file: /etc/named.rfc1912.zones

Edit the main configuration file

[root@localhost ~]# vim /etc/named.conf


DNS service resolution

Forward resolution (find the corresponding IP address based on the host name (domain name))

1. Configure zone data information (zone information is stored in: /etc/named.rfc1912.zones file, just add content at the end)

[root@localhost ~]# vim /etc/named.rfc1912.zones
zone "chuid.com" IN {
        type master;
        file "chuid.com.zone";
        allow-update { none; };
};


2. Configure parsing data information (switch to the bind (/var/named) working directory and view the permissions of the area data file)

The data file for forward analysis is: /var/named/named.localhost

[root@localhost ~]# cd /var/named
[root@localhost named]# ls -la named.localhost named.loopback 
-rw-r-----. 1 root named 152 6月  21 2007 named.localhost
-rw-r-----. 1 root named 168 12月 15 2009 named.loopback

cp -a together with copy the attributes, owner, group and other information of the original file

localhost named]# cp -a named.localhost chuid.com.zone
localhost named]# cp -a named.loopback chuid.com.arpa

Edit the zone data file of the chuid.com domain name

[root@localhost named]# vim chuid.com.zone
         NS            ns.chuid.com.
ns       IN A          192.168.203.202
         IN MX 10      mail.chuid.com.
mail     IN A          192.168.203.202
www      IN A          192.168.203.202
bbs      IN A          192.168.203.202

Use the vim command to add the following configuration at the end of the chuid.com.zone file 

Reverse resolution (find the corresponding host name (domain name) according to the IP address)

1. Configure zone data information (zone information is stored in: /etc/named.rfc1912.zones file, just add content at the end)

[root@localhost ~]# vim /etc/named.rfc1912.zones
zone "203.168.192.in-addr.arpa" IN {
        type master;
        file "chuid.com.arpa";
        allow-update { none; };
};

2. Configure the analysis data information (just write the new area information to the back)

The reverse analysis data file is: /var/named/named.loopback

[root@localhost named]# vim chuid.com.arpa
         IN NS      ns.chuid.com.
ns       IN A       192.168.203.202    #PTR为指针记录,仅用于反向解析中。
202      IN PTR     mail.chuid.com
202      IN PTR     www.chuid.com
202      IN PTR     bbs.chuid.com

Restart the named service to make the configuration file effective immediately

[root@localhost named]# systemctl restart named

Test DNS server

Open the windows client and modify the DNS of win 7 to server-side DNS

The normal access to the resolved domain name proves that the DNS server is successfully set up

 

Common errors are reported when restarting the named service program

[root@localhost named]# systemctl restart named
Warning: named.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[root@localhost named]# systemctl daemon-reload
[root@localhost named]# systemctl restart named
[root@localhost named]#

 

Guess you like

Origin blog.csdn.net/C_huid/article/details/101073321