Linux_DNS domain name forward resolution specific configuration!

1. DNS overview

1. The role of the system

Forward resolution: Find the corresponding IP address based on the domain name

Reverse resolution: Find the corresponding domain name based on the IP address

2. Definition of DNS

DNS is the English abbreviation of "City Name System". As a distributed database that maps domain names and IP addresses to each other, it can make it easier for people to access the Internet.

DNS service uses TCP and UDP port 53,

TCP port 53 is used to connect to the DNS server, and UDP port 53 is used to resolve DNS.

The length of each first-level domain name is limited to 63 characters, and the total length of the domain name cannot exceed 253 characters.

  • Root domain : located at the top level of the tree structure, represented by "."

  • Top-level domain : generally represents a type of organization or country;
    such as .net (network provider), .com (business enterprise), .org (group organization), .edu (educational structure), .gov (government department) ), .cn (Chinese national domain name)

  • Second-level domain : used to indicate a specific organization in the top-level domain. The second-level domain names under the national top-level domain are managed by the national department.

  • Subdomains : All levels of domains created under the second-level domains are collectively referred to as subdomains. Each organization or user can freely apply to register their own domain names

  • Host : The host is located at the lowest level of the domain name space and is a specific computer

2. Types of DNS server

  • Primary domain name server : responsible for maintaining all domain name information of an area, it is the authoritative information source of all specific information, and the data can be modified. When constructing the main domain name server, you need to create the address data file of the area in charge by yourself.

  • Secondary domain name server : When the primary domain name server fails, shuts down, or is overloaded, the secondary domain name server serves as a backup service to provide domain name resolution services. The resolution result provided from the domain name server is not determined by yourself, but comes from the main domain name server. When constructing the secondary domain name server, you need to specify the location of the master domain name server so that the server can automatically synchronize the address database of the area.

  • Cache domain name server : only provides the cache function of domain name resolution results to improve query speed and efficiency, but there is no domain name database.
    It obtains the result of each domain name server query from a remote server, puts it in the cache, and uses it to respond when querying the same information later. The cache domain name server is not an authoritative server, because all the information provided is indirect information. When constructing a cache domain name server, you must set the root domain or designate another DNS server as the source of resolution.

  • Forwarding domain name server : responsible for local queries of all non-local domain names. After the forwarding domain name server receives the query request, it searches in its cache, and if it cannot find it, it forwards the request to the specified domain name server in turn until the result is found, otherwise it returns a result that cannot be mapped.

3. Experimental steps

1. Install the bind package

[root@localhost ~]# yum install -y bind

Insert picture description here

2. Configure forward analysis

  • 1. First check the path of the configuration file that needs to be modified
rpm -qc bind                   #查询bind软件配置文件所在路径
/etc/named.conf                #主配置文件
/etc/named/rfc1912.zonrs       #区域配置文件
/var/named/named.localhost     #区域数据配置文件

Insert picture description here

  • 2. Modify the main configuration file
vim /etc/named.conf
options {
    
    
  listen-on-v6 poet 53 {
    
     192.168.184.10; };              #监听53端口,IP地址使用提供服务的本地IP,也可用any代表所有
listen-on-v6 port 53 {
    
     : :1; };                      #ipv6行如不使用可以注释掉或者删除
  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; };                                                #允许使用本DNS解析服务的网段,也可用any代表所有

zone "." IN {
    
                                                #正向解析“. "根区域
        type hint;                                       #类型为根区域
        file "named.ca";                                 #区域数据文件为named.ca,记录了13台根域服务器的域名和IP地址等信息
};

Insert picture description hereInsert picture description here

  • 3. Modify the zone configuration file and add reverse zone configuration
vim /etc/named.rfc1912.zones             #文件里有模版,可复制粘贴后修改
zone "benet.com" IN {
    
                          #正向解析benet.com区域
        type master;                       #类型为主区域
        file "bent.com.zone";             #指定区域数据文件为bent.com.zone
        allow-update {
    
     none; };
};

Insert picture description here

Insert picture description here

  • 4. Configure the forward zone data file

Insert picture description here
Insert picture description here

  • 5. Start the service and turn off the firewall

Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

  • Parse into the virtual machine:

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/Wsxyi/article/details/113952269