Article Title: Design of a Linux-based network experiment system (III ). 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.
Chapter 3 DNS (Domain Name System) and settings
Section 1 DNS introduction
I. DNS
Each network interface connecting TCP/IP is identified by a unique 32-bit IP address. However, the numbers are complex, hard to remember, and have no image. Therefore, people invented the domain name system to solve it. in this case, we can use easy-to-understand and more vivid names as the identification of a computer. In most cases, the digital address and domain name address can be used together. However, no matter the digital address or domain name is used for network applications, the network is always based on the IP address. Before connecting to the network, the system must convert the domain name address to an IP address. This is the DNS task.
There are two common methods to convert a domain name to an IP address. An old method is to find the host name from a file called "host table". later, a distributed database system called "Domain Name Service (DNS)" is generally used, converts a name to an IP address.
A host table is a simple text file that associates IP addresses with host names. In Redhat5.2, the host table file is/etc/hosts. each table item in this file contains an IP address and a list of associated host names separated by spaces.
Although the host table is relatively simple, it has some disadvantages. The domain name system can overcome these shortcomings:
-Good DNS scalability. It does not rely on a single large table, but a distributed database system. it will not be in trouble due to the growth of the database.
-DNS ensures that information about the new host is transmitted to other parts of the network when necessary. Not only can information be automatically transmitted, but only the required information can be disseminated.
DNS works as follows: if a DNS server receives a request to obtain information about the host, it sends the request to a management server. The management server is any server that maintains the precise information of the query domain. When it responds to this request, the local server saves the response information in the cache for future use. When the local server receives a request for this information again, it replies to this request.
II. DNS server type
1. "Cache-Only" DNS server:
A dns server cannot have all the host information on the international network. Therefore, it provides a forwarding method to forward the query requests that cannot be processed by its own DNS server to the top-level DNS server for query, then, the obtained query results are sent to the host requesting the query. The "DNS" of "Cache-Only" means that the host information of the DNS server does not exist except itself. it forwards all query requirements to other DNS servers for query.
2. "Primary" DNS server:
A fully functional DNS server that manages the information of one or more "Domain" machines. The host-related information is stored in the file directory of the server according to the format, and will then be read into the system when the server starts.
"Secondary" DNS server:
Basically, it is also a complete DNS server, but the difference is that its host information is not completely stored in the server's archive directory, it is provided by a "Primary DNS.
Our experimental system will be a "Primary" DNS server, which provides local LAN user queries and caches other requests.
Section 2 DNS settings
I. application conditions
I already have DNS software installed on Linux. I use BIND (Berkeley Internet Name Domain Name Server), which is the most widely used in the Internet, version 8.
Our application conditions are as follows:
1. a Class c cidr block address (172.31.0 );
2. the domain name is ec.edu (the master domain name server address is 172.31.0.10, and the host name is Linuxserver.ec.edu );
3. the LAN is connected to the Internet through a gateway.
The main body of the DNS server is the domain name server process named. after the named is started, it provides the domain name resolution service to the DNS client and converts the domain name to an IP address.
When named is started, several data files need to be read. in bind 4,/etc/named. boot is used by default, so/etc/named. boot is the basic configuration file of named. In bind 8,/etc/named. conf is used by default. (Note that red hat 5.1 comes with bind 4, while red hat 5.2 comes with bind 8. I spent a lot of time on it ).
Although named can be directly executed when it is started, we can use ndc, a tool for controlling named in Linux. Ndc can be used to start, stop, restart, refresh DNS data, output DNS data, and other debugging functions. I am using this tool to help debug the DNS server.
2. create the named configuration file/etc/named. boot and etc/named. conf.
1./etc/named. boot is a basic configuration file, but does not contain any DNS data. for the previous settings, first create the following/etc/named. boot, the content is as follows:
; Boot file for name server
Directory/var/named
Domain ec.edu named. hosts
Primary 0.0.127.in-addr. arpa named. local
Primary 0.31.0.172.in-addr. arpa named. rev
Cache. named. ca
The line starting with ";" is a comment line. The meanings of other lines are as follows:
(1) diretory/var/named: specify the named to read the DNS data file from the/var/named Directory. you can specify and create this directory by yourself, all DNS data files are stored in this directory;
(2) domain ec.edu named. hosts: specify named as the master domain name server of the ec.edu domain. the named. hosts file contains all domain name conversion data in the form of * .ec.edu;
(3) primary 0.0.127.IN-ADDR. ARPA named. local: specify the named as the 127.0.0 CIDR block to the master server. the local file contains 127.0.0. * form of address-to-domain name conversion data (127.0.0 segment address is the internal loopback address of the LAN interface );
(4) primary 0.31.0.172.in-addr. arpa named. rev: specify the named as the master server for IP address translation of 172.31.0. the rev file contains all 172.31.0. * Convert data from an address to a domain name;
(5) cache. named. ca: specify named to obtain the top-level "root" server address of the Internet from the named. ca file.
(3) and (4) the network segment addresses in the two lines are written in reverse mode. In addition, the names of each file can also be determined by yourself.
2. the/etc/named. conf file is a basic configuration file that does not contain any DNS data. for the previous settings, create the following/etc/named. conf file. its content is as follows:
// Generated by named-bootconf.pl
Options {
Directory "/var/named ";
// Query-source address * port 53;
};
// A caching only nameserver config
Zone "." {
Type hint;
File "named. ca ";
};
Zone "0.0.127.in-addr. arpa "{
Type master;
File "named. local ";
};
//-------------------------------
Zone "0.31.172.in-addr. arpa "{
Type master;
File "named. rev ";
};
Zone "ec.edu "{
Type master;
File "named. hosts ";
};
// These are the added content
//-------------------------------
This file can also be converted from named. boot using a named-bootconf.pl script.
3. create various DNS data files
Now, you need to create various DNS data files according to the definition in/etc/named. boot.
1. create a forward domain name conversion data file named. hosts
According to the definition of/etc/named. boot, we create named. hosts under the/var/named directory, which should include all host nodes in the ec.edu domain. However, for the convenience of debugging, it is recommended that data of several nodes be put into the file at the beginning, and the data of other nodes be added after the named works properly. The following is an example of named. hosts:
@ In soa LinuxServer.ec.edu. root.LinuxServer.ec.edu .(
1999051702; serial
36000; refresh
8640; retry
360000; expire
86400); minim
In ns LinuxServer.ec.edu.
MX 10 LinuxServer.ec.edu.
Localhost in a 127.0.0.1
LinuxServer in a 172.31.0.10
O2 in a 172.31.0.1
Ntsever in a 172.31.0.110
W100 in a 172.31.0.100
W101 in a 172.31.0.101
W102 in a 172.31.0.102
W103 in a 172.31.0.103
W104 in a 172.31.0.104
W105 in a 172.31.0.105
W106 in a 172.31.0.106
W107 in a 172.31.0.107
W108 in a 172.31.0.108
W109 in a 172.31.0.109
W111 in a 172.31.0.111
W112 in a 172.31.0.112
W113 in a 172.31.0.113
W114 in a 172.31.0.114
W115 in a 172.31.0.115
W116 in a 172.31.0.116
W117 in a 172.31.0.117
W118 in a 172.31.0.118
W119 in a 172.31.0.119
W120 in a 172.31.0.120
Gateway in a 172.31.0.200
Mail MX 10 Linuxserver.ec.edu.
Www CNAME Linuxserver.ec.edu.
Ftp CNAME Linuxserver.ec.edu.
...
The first line is the SOA record, which defines the basic information of domain name data, which is the DNS server name and DNS administrator email address (here "@" ". "Replace), the first number in the brackets is the file version number (generally the time of the day and the number of modifications), each time the content of this file is repaired
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.