Linux Domain Name Service DNS Configuration Method

Linux Domain Name Service DNS Configuration Method

What is DNS

The full name of DNS is Domain Name System, which means domain name resolution system. Its responsibility is to translate domain names into recognizable IP addresses for different computer devices to connect to.

Linux DNS resolution configuration and files

There are three files in Linux related to DNS resolution:

  • /etc/hosts records the IP address corresponding to the hostname
  • /etc/resolv.conf sets the IP address of the DNS server
  • /etc/host.conf specifies the order of domain name resolution (whether to resolve from the local hosts file or from DNS)
  • The existence of /etc/hosts is that the early network was not particularly developed, and simply storing the correspondence between host names and IP addresses in hosts was sufficient to meet the needs. With the development of the network, distributed DNS services gradually emerged, but the /etc/hosts format was retained.

/etc/resolv.conf is used to configure the DNS domain name and IP address. There is a lot of information on the Internet for reference.

How a domain name is resolved

How the Domain Name System (DNS) Works explains the process of how a domain name is resolved, which can be basically divided into:

  • Request the root domain name service for the domain name service where the top-level domain name is located
  • Requesting second-level domain name service from top-level domain name service
  • Request a specific IP address from the secondary domain name service

Simple DNS configuration example (based on CentOs7)

Server Side

1. Install bind

yum install bind

2. Modify the /etc/named.conf configuration file

vim /etc/named.conf
options {
    listen-on port 53 { any; }; //Open listening port 53 and accept any IP connection listen-on-v6 port 53 { ::1; }; //Support IP V6
    directory "/var/named"; //All forward and reverse zone files are created in this directory 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 { 0.0.0.0/0; }; //Allow any IP to query recursion yes;
    dnssec-enable yes;
    dnssec-validation yes;
    dnssec-lookaside auto;
    /* Path to ISC DLV key */
    bindkeys-file "/etc/named.iscdlv.key";
    managed-keys-directory "/var/named/dynamic";

};

logging {
    channel default_debug {
        file "data/named.run";
        severity dynamic;
    };
};

zone "." IN {
    type hint;
    file "named.ca";
};

include "/etc/named.rfc1912.zones"; //Main configuration file include "/etc/named.root.key";

3. Modify the /etc/named.rfc1912.zones file and add the forward zone of duiyi.com

vim /etc/ named.rfc1912.zones
zone "localhost.localdomain" IN {
    type master;
    file "named.localhost";
    allow-update { none; };
};

zone "localhost" IN {
    type master;
    file "named.localhost";
    allow-update { none; };
};

zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
    type master;
    file "named.loopback";
    allow-update { none; };
};

zone "1.0.0.127.in-addr.arpa" IN {
    type master;
    file "named.loopback";
    allow-update { none; };
};
zone "0.in-addr.arpa" IN {
    type master;
    file "named.empty";
    allow-update { none; };
};

//duiyi.com's positive zone zone "duiyi.com" IN {
    type master;
    file "duiyi.com.zone";
    allow-update { none; };
};

4. Create a forward zone resource file

vim /var/named/duiyi.com.zone
$TTL 1D
@ IN SOA duiyi.com. rname.invalid. (
                    0 ; serial
                    1D ; refresh
                    1H ; retry
                    1W ; expire
                    3H ) ; minimum
    NS@
    A 127.0.0.1
    AAAA::1
www IN A 192.168.81.1
mail IN A 192.168.81.2
ftp IN A 192.168.81.3

5. Start the named service

systemctl start named

6. Start automatically at boot

systemctl enable named

## Client operating system: Both Windows and Linux are acceptable
IP address: Any IP address that can ping the DNS server (192.168.81.133) will do.
Function: Test whether the DNS server is working properly.

1. Modify DNS:


2. Ping the server IP (192.168.81.133) to test whether the server can be accessed


3. Use the nslookup command to test whether the three DNS resolutions are successful


As shown in the figure, it means that the DNS forward resolution is successful

Linux as client test:

1. Install the bind-utils package so that you can use the nslookup, dig, and host tools

yum install bind-utils

2. Modify the DNS configuration to use our DNS server

vim /etc/resolv.conf
nameserver 192.168.81.133
nameserver 114.114.114.114
nameserver 8.8.8.8

3. Forward resolution test, use the nslookup command (same as the windows test)

nslookup

Summarize

The above is the Linux domain name service DNS configuration method introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor 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:
  • Detailed explanation of how to configure secondary domain name on Apache server under Linux environment
  • How to modify IP, DNS and routing command line configuration in Linux
  • How to configure dnsmasq as dns cache server in Linux
  • Example of querying DNS in Linux
  • How to modify IP, gateway, and DNS in Linux command line
  • How to quickly make DNS changes take effect in Linux
  • Build your own CDN with DNSPod and Squid (Part 3) Install CentOS Linux
  • Summary of commands to clear DNS cache under Mac OS X/Linux system

<<:  react-diagram serialization Json interpretation case analysis

>>:  MySQL 8.0.12 Installation and Configuration Tutorial

Recommend

Vue3 (Part 2) Integrating Ant Design Vue

Table of contents 1. Integrate Ant Design Vue 2. ...

How to add fields to a large data table in MySQL

Preface I believe everyone is familiar with addin...

Design of image preview in content webpage

<br />I have written two articles before, &q...

CentOS uses local yum source to build LAMP environment graphic tutorial

This article describes how to use the local yum s...

Vue image cropping component example code

Example: tip: This component is based on vue-crop...

Summary of several error logs about MySQL MHA setup and switching

1: masterha_check_repl replica set error replicat...

vue3 custom directive details

Table of contents 1. Registering custom instructi...

JSONP cross-domain simulation Baidu search

Table of contents 1. What is JSONP 2. JSONP cross...

How to modify the default storage engine in MySQL

mysql storage engine: The MySQL server adopts a m...

The difference and usage of datetime and timestamp in MySQL

1. How to represent the current time in MySQL? In...

Docker large-scale project containerization transformation

Virtualization and containerization are two inevi...

A complete guide to the Docker command line (18 things you have to know)

Preface A Docker image consists of a Dockerfile a...

7 skills that web designers must have

Web design is both a science and an art. Web desi...

Docker time zone issue and data migration issue

Latest solution: -v /usr/share/zoneinfo/Asia/Shan...