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

Detailed steps for debugging VUE projects in IDEA

To debug js code, you need to write debugger in t...

Why do code standards require SQL statements not to have too many joins?

Free points Interviewer : Have you ever used Linu...

Vue3 list interface data display details

Table of contents 1. List interface display examp...

JavaScript CollectGarbage Function Example

First, let's look at an example of memory rel...

Introduction to Linux File Compression and Packaging

1. Introduction to compression and packaging Comm...

Deeply understand how nginx achieves high performance and scalability

The overall architecture of NGINX is characterize...

Detailed explanation of the execution process of mysql update statement

There was an article about the execution process ...

How to use union all in MySQL to get the union sort

Sometimes in a project, due to some irreversible ...

Docker binding fixed IP/cross-host container mutual access operation

Preface Previously, static IPs assigned using pip...

Docker FAQ

Docker only maps ports to IPv6 but not to IPv4 St...

Solve the problem of secure_file_priv null

Add secure_file_priv = ' '; then run cmd ...

The best 9 foreign free picture material websites

It is difficult to find good image material websi...

mysql backup script and keep it for 7 days

Script requirements: Back up the MySQL database e...

Solution to transparent font problem after turning on ClearType in IE

The solution to the transparent font problem after...