Easy Guide to building a DNS server

Source: Internet
Author: User
Tags add definition end ftp first row version domain name registration nslookup
In a network set up with the TCP/IP protocol family, each node has a unique IP address that is used as their only token. However, it would be unthinkable if the user were to be remembered for such an IP address without a memory rule. People need a string of memory rules to be the name of a unique tag node.

However, although the symbol name is very convenient for people, it is not so convenient to implement on the computer. In order to solve this demand, a Domain Name Service system DNS, which runs on the TCP protocol, is responsible for converting the character name-domain name to the corresponding IP address. This process is the domain name resolution, is responsible for the domain name resolution machine is called the domain name server.

1, the method of domain name resolution

1.1 The first domain name resolution method

The simplest method of host name resolution is to record all the host names and their corresponding IP addresses in a file, and to ensure the uniqueness of the hostname in the file, and to complete the resolution of the host name by retrieving the file. There are historical reasons for adopting this simplest approach:

Throughout the 70 's, Apranet was only a small group composed of similar hundreds of hosts. In order to solve the problem of host name resolution, the name of each host connected to the ARPANET and the corresponding address are saved in the HOSTS.TXT file. So every time you add a machine, you must modify the HOSTS.TXT file once. With the continuous development of the network, the number of hosts in the network explosive increase, this method of domain name resolution has been unable to adapt to the new resolution needs.

1.2 Distributed domain name servers

In this way, we have detailed descriptions in the sixth chapter of the basic article, which we will not repeat here. In this distributed Domain Name server system, each domain name server (DNS) is responsible for resolving its own part of this host domain name.

Generally speaking, if you are in the company or the organization has not many hosts, is generally the domain name parsing work to the ISP's domain name server to complete. And if your organization has more hosts, we can build our own domain name server to resolve the host of your organization.

2, the Domain name server establishes the example

2.1 Instance Environment

Suppose we need to set up a business name server that applies to the following conditions.

1. Have a Class C network segment address, for 202.101.55.0

2. Enterprise Domain name registration for company.com.

3. The IP of the domain name server is set to 202.101.55.55 and the host name is dns.company.com. It acts as a proxy at the same time.

4. The enterprise network is connected to the Internet through a router.

5. The servers to resolve are:

Www.company.com (202.101.55.1) Web server

Mail.company.com (202.101.55.2) e-mail server

2.2 Pre-installation preparatory work

First of all, it is necessary to ensure that there are/etc/resolv.conf and/etc/hosts.conf two documents in the department. The contents of the/etc/resolv.conf file are as follows:

Domain compay.com

NameServer 202.101.55.55

The first line indicates the domain that the host that you want to connect to should search for. And the second line indicates at which address you can find the required domain Name service large. The contents of the/etc/hosts.conf are shown below:

Order Hosts,bind

Multi on

The settings here tell the host name to search in the/etc/hosts file first, and then query the domain name server.

2.3 Definition File/etc/named.boot

To enable the Linux system to complete the function of the domain name server, you need to run a named service process. This service process can be selected when Linux is installed.

Named needs to read an initialization file--/etc/named.boot when it is started, which is the basic configuration file for named. It does not contain any DNS data, and for the preceding hypothetical environment, we will write in this file:

Diretory/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

Let's go through the contents of this document line by row:

1 in the first row we specify that named read the DNS data files from the/etc/named directory. This directory can be specified and created by itself, specifying that all DNS data files are stored in this directory;

2 The second line specifies named as the primary domain name server for the company.com, and Db.company file contains parsing data for all *.my.com forms of domain names.

3 The third row specifies named as the conversion master server for the 127.0.0 network segment (local loopback) address. The db.127.0.0 file contains the conversion data for all 127.0.0.* forms of address to the domain name.

4 The fourth row specifies named as the 202.101.55 network segment address Conversion master server, db.202.101.55 file contains all the 202.101.55.* form of address to the domain name of the conversion data.

5 The last line specifies that named obtains the top-level "root" server address of the Internet from the Db.cache file. It is to be explained that the names of these data files are determined by themselves.

2.4 Establishing a forward domain conversion data file Db.company

Based on 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 previously assumed environment, you can write to:

@ in SOA dns.company.com. Root.dns.company.com. (

200002011. File version number

28800; Refresh Time (sec)

7200; retry time (seconds)

3600000; End Time (sec)

86400); TTL lifetime (sec)

In NS dns.company.com

www in A 202.101.55.1

Email in A 202.101.55.2

Proxy in CNAME

Here's a step-by-step understanding of the configuration here.

1. SOA is a command that must be set in the master server settings file, and we usually place it on the first line of the file.

1 The first symbol "@" represents the domain currently under jurisdiction.

2 Then "in" represents the address category, which is fixed using "in".

3) Next is the command SOA.

4 Next fill in the domain name server, remember that due to the special format of DNS data files, in the end must be added "•", in this example, we fill in the Domain name server: "Dns.company.com."

5 Next is the domain name server Administrator's e-mail address, but note that the e-mail address of the separator "@" here with "·" To replace, and in the end to add ". "Here, we write accordingly:" root.dns.company.com. "

6 Next in parentheses fill in the various options:

File version number: When you modify the contents of this file, you also need to modify this version of the serial number. Use this to distinguish whether there is an update.

Update Time: Specifies the update time period for the secondary server to copy data to the primary server.

Retry time: Specifies the retry time for the secondary server when a communication failure occurs.

End time: Specifies when the secondary server will be unable to complete the update task and terminate the update after the update action has been rerun.

Lifetime: Specifies when a domain name server asks for a domain name and its IP address to place on the domain name server.

Note: The domain name server set by the secondary server is the backup host of the primary server.

2. In the second line, we use the NS command to specify the domain's domain name server. Here we point out that the domain's domain name server is "Dns.company.com".

3. In the next two lines we use a command to specify the corresponding relationship between the domain name and the IP address. We correspond the domain 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. On the last line, we used the CNAME command to specify another domain name for dns.company.com for use: proxy.company.com.

2.5 Establish 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 IP address query corresponding DNS host name, each network segment has a data file.

1. Network segment 127.0.0 usually have only one address, that is 127.0.0.1 loopback address. So what we write in the db.127.0.0 is:

@ in SOA dns.company.com. Root.dns.company.com. (

200002011. File version number

28800; Refresh Time (sec)

7200; retry time (seconds)

3600000; End Time (sec)

86400); TTL lifetime (sec)

In NS dns.company.com

1 in PTR localhost

The first two believe that the reader is no stranger, the last sentence we use the PTR command to allow the host in the configuration file to use the IP address to know the corresponding domain name.

The first 1 represents 127.0.0.1, the corresponding domain name is localhost.

2. The network segment 202.101.55 may have more records, the preceding assumes the environment setting should be:

@ in SOA dns.company.com. Root.dns.company.com. (

200002011. File version number

28800; Refresh Time (sec)

7200; retry time (seconds)

3600000; End Time (sec)

86400); TTL lifetime (sec)

In NS dns.company.com

1 in PTR www

2 in PTR email

In PTR DNS

In PTR Proxy

2.6 Obtaining Db.cache Files

A named.ca file is typically provided in a Linux system, the top-level domain name server for the Internet in the file, but this file is usually changed, so it is recommended that you download the latest version from the Internet. The file can be downloaded from the Ftp.rs.internic.net/domain via anonymous FTP, and the filename is named.boot. A copy of it for Db.cache is OK.

3, test the domain name server

3.1 Using Nslookup test

The function of the nslookup command is to query the data in the domain name server. The following example uses it to test whether a domain name server is set up successfully, where the italic character represents the content to be entered.

# nslookup

Default server:dns.company.com

address:202.101.55.55; to be able to appear these information represents success

"www

Server:dns.company.com

address:202.101.55.1

3.2 Using the ping test

A simpler way to test this is to use the ping command if success will show:

# pingwww.company.com

Pingwww.company.com (202.101.55.1); data bytes

Bytes from 202.101.55.1:icmp_seq=0 ttl=255 time=1.3ms

Bytes from 202.101.55.1:icmp_seq=1 ttl=255 time=0.6ms

Bytes from 202.101.55.1:icmp_seq=2 ttl=255 time=0.6ms

......

8.4 Tips

When you install a domain name server, you will find that the speed is very slow when you use the domain name for remote connections internally. In fact, as long as the/etc/hosts in addition to all the internal machine domain name on it.



Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.