Article Title: Linux networking entry (5): DNS server. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
In a network set up using a TCP/IP protocol family, each node has a unique IP address, which is used as its unique identifier. However, it is unimaginable for users to remember these IP addresses without any memory. People need a string with regular memory to use as the unique name to mark the node.
However, although the symbolic name is extremely convenient for people, it is not so convenient to implement it on the computer. To solve this problem, a Domain Name Service System (DNS) was created. It runs on the TCP protocol and is responsible for converting the character name-domain name to the actual corresponding IP address. This process is domain name resolution. The machine responsible for domain name resolution is called the Domain Name Server.
8.1 domain name resolution Method
8.1.1 earliest domain name resolution Method
The simplest method of host name resolution is to record all host names and their corresponding IP addresses in a file and ensure the uniqueness of the host names in the file, you can retrieve the file to complete host name resolution. There are historical reasons for using this simplest solution:
Throughout 1970s, APRANET was a small group of hundreds of hosts. To solve the host name resolution problem, the names and corresponding addresses of each host connected to ARPANET are saved in the HOSTS. TXT file. In this way, the HOSTS. TXT file must be modified once every time a machine is added. With the continuous development of the network, the number of hosts in the network increases explosively. This domain name resolution method can no longer meet the new resolution needs.
8.1.2 distributed Domain Name Server
This method has been described in detail in chapter 6 of the basic article, so we will not repeat it here. In this distributed Domain Name Server system, each Domain Name Server (DNS) is responsible for parsing the domain names of its own host.
Generally, if you have a small number of hosts in a company or organization, you can resolve the domain name to your ISP's Domain Name Server. If you have a large number of hosts in your organization, we can set up our own Domain Name Server to resolve the hosts in your organization.
8.2 create an instance for the Domain Name Server
8.2.1 instance Environment
Suppose we need to create a Domain Name Server for a business owner that applies to the following situations.
1. Has a class c cidr block address, which is 202.101.55.0
2. register an Enterprise Domain Name as company.com.
3. Set the IP address of the Domain Name Server to 202.101.55.55 and the host name to dns.company.com. It also acts as Proxy.
4. Connect a cen instance to the Internet through a vro.
5. the servers to be parsed include:
Www.company.com (202.101.55.1) Web Server
Mail.company.com (202.101.55.2) email server
8.2.2 preparations before installation
First, ensure that the/etc/resolv. conf and/etc/hosts. conf files are in the system.
The/etc/resolv. conf file contains the following content:
Domain compay. comnameserver 202.101.55.55
The first line indicates the domain to be searched for any host to connect to it. The second line shows the address at which the Domain Name Service is needed.
The content of/etc/hosts. conf is as follows:
Order hosts, bindmulti on
The settings here tell the host name to be searched in the/etc/hosts file before querying the Domain Name Server.
8.2.3 definition file/etc/named. boot
To enable the LINUX system to complete the functions of the Domain Name Server, you need to run a named service process. This service process can be selected when LINUX is installed.
When starting named, you need to read an initialization file --/etc/named. boot, which is the basic configuration file of named. It does not contain any DNS data. For the previous hypothetical environment, we need to write in this file:
Diretables/etc/named
Primary company.com db. company
Primary 0.0.127.IN-ADDR. ARPA db.127.0.0
Primary 55.101.202.IN-ADDR. ARPA db.202.101.55
Cache. db. cache
Next we will explain the content in this file line by line:
1) In the first line, specify named to read DNS data files from the/etc/named directory. You can specify and create this directory, and store all DNS data files in this directory;
2) The second row specifies the named as the master Domain Name Server of company.com. The db. company file contains all the domain name resolution data in the form of * .my.com.
3) in the third row, specify the named as the master server for converting the 127.0.0 network segment (local loopback) address. The db.127.0.0 file contains all the address-to-Domain Name conversion data in the form of 127.0.0.
4) The fourth line specifies the named as the master server for the 202.101.55 CIDR block address conversion. The db.202.101.55 file contains all the address-to-Domain Name conversion data in the form of 202.101.55.
5) the last row specifies the named to get the top-level "root" server address of the Internet from the db. cache file.
Note that the names of these data files are self-determined.
8.2.3 create a forward domain name conversion data file db. company
According to the definition in the/etc/named. boot file, we create the file db. company in the/etc/named directory and write all the host nodes in the company.com domain. Based on the preceding environment, you can write:
@ In soa dns.company.com. root.dns.company.com .(
200002011; file version number
28800; refresh time (seconds)
7200; retry time (seconds)
3600000; End Time (seconds)
86400); TTL survival time (seconds)
In ns dns. company. comwww
In a 202.101.55.1email
In a 202.101.55.2proxy
In cname dns
Next we will understand the configuration here one by one.
1. SOA is a command that must be set in the configuration file of the master server. We usually place it on the first line of the file.
1) the symbol "@" at the beginning represents the domain currently under the jurisdiction.
2) The next "IN" indicates the address category. Here "IN" is used.
3) The following is the command SOA.
4) Fill in the Domain Name Server. Remember to add "·" to the end due to the special format rules of the DNS data file. In this example, fill in the Domain Name Server: "dns.company.com ."
5) next is the E-MAIL address of the Domain Name Server administrator, but note that the separator "@" in the e-mail address is replaced by "·" here, add ". ", Here, we write: "root.dns.company.com ."
6) Fill in the following options in brackets:
File version: When you modify the content of this file, you also need to modify the version serial number. To identify whether updates exist.
Update Time: Specifies the update time period for the second-level server to copy data to the master server.
Retry time: Specify the retry time when the second-level server updates a communication fault.
End Time: the time when the update task cannot be completed after the second-level server executes the update operation again.
Survival time: specifies the time when the Domain Name Server places a domain name on the Domain Name Server after asking for a domain name and its IP address.
Note: The Domain Name Server set by the second-level server is the backup host of the master server.
2. In the second line, we use the NS command to specify the Domain Name Server for this domain. Here we point out that the Domain Name Server in this domain is "dns.company.com ".
3. In the next two lines, we will use the command to specify the ing between the domain name and the IP address. We map the domain name www.company.com of the Web server to its IP address 202.101.55.1, and the domain name mail.company.com of the E-Mail server to its IP address 202.101.55.2.
4. In the last line, we used the CNAME command to specify another domain name for dns.company.com for use: proxy.company.com.
8.2.3 create Reverse Domain Name conversion data files db.127.0.0 and db.202.101.55
The Reverse Domain Name conversion data file is used to provide an IP address to query the corresponding DNS host name. Each network segment has a data file.
1. The CIDR Block 127.0.0 usually has only one address, that is, 127.0.0.1 loopback address. So what we write in db.127.0.0 is:
@ In soa dns.company.com. root.dns.company.com .(
200002011; file version number
28800; refresh time (seconds)
7200; retry time (seconds)
3600000; End Time (seconds)
86400); TTL survival time (seconds)
In ns dns. company. com1
In ptr localhost
The first two are believed to be familiar to the readers. In the last sentence, we use the PTR command to allow hosts in the configuration file to use IP addresses to know the corresponding domain name.
The first 1 represents 127.0.0.1, and the corresponding domain name is localhost.
2. More records may exist in the CIDR Block 202.101.55. The preceding settings are assumed to be:
@ In soa dns.company.com. root.dns.company.com .(
200002011; file version number
28800; refresh time (seconds)
7200; retry time (seconds)
3600000; End Time (seconds)
86400); TTL survival time (seconds)
In ns dns. company. com1
In ptr www2
In ptr email55
In ptr dns55
In ptr proxy
8.2.4 obtain the db. cache file
In LINUX, a named is usually provided. ca file, which contains the top-level domain name server on the Internet, but this file usually changes. Therefore, we recommend that you download the latest version from the Internet. The file can be downloaded from ftp.rs.internic.net/domainvia anonymous FTP with the file name named.boot. Copy it As db. cache.
8.3 Test the Domain Name Server
8.3.1 Test with nslookup
The nslookup command is used to query data in the Domain Name Server. In the following example, we use it to test whether the Domain Name Server has been successfully set up.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service