Domain name resolution system settings in linux

Source: Internet
Author: User
Tags nameserver nslookup nslookup command
In linux, the domain name resolution system settings-Linux Enterprise Application-Linux server application information are as follows. ① Introduction

DNS is the Domain Name System, which can convert a Domain Name such as www.21php.com to an IP address such as 211.152.50.35. If there is no DNS, When you browse the website 21php.com, you must use numbers that are so hard to remember as 211.152.50.35. The DNS server provides the DNS service. There are three types of DNS servers: Cache-only server, Primary Name server, and Second Name Server ).

The detailed principles, workflows, terms, and concepts of DNS are limited by space. Can read special articles such as DNS-HOWTO to learn.

② Configure the primary DNS Server

First, let's make the following assumptions: server A is the primary Domain Name Server of 21php.com, its IP address is 11.0.0.1, server B is the secondary Domain Name Server of 21php.com, and its IP address is 11.0.0.2;

Next we configure the primary DNS server 11.0.0.1 as 21PHP. COM.

The dns function in Linux is implemented through the bind software. After the bind software is installed, several inherent files are generated, which can be divided into two categories: configuration files under the/etc directory and dns record files under the/var/named directory. Add other related files to set up the dns server. The following is a list and description of all files related to dns settings.

Hosts, host. conf, resolv. conf, named. boot, and named. conf are located in the/etc directory.

1. In the "hosts" file, the host name and IP address are defined, and the IP address and Host Name of the computer that will run dns are also defined. Content:

127.0.0.1 localhost. localdomain localhost

2. "host. conf file [Boban Note: originally written as hosts. conf], "order hosts bind" Statement, specifying the resolution order for the host name is first found in hosts, and then found in the dns server record. "Multi on" allows a host name to correspond to multiple IP addresses. Content:

Order hosts, bind

Multi on

Nospoof on

3. In the "resolv. conf" file, "nameserver 10.0.0.211" specifies the address of the dns server. Note: This file is essential for computers that do not use dns servers (non-windows systems; Windows systems set this file in "Network Properties. If you have not set the local machine as a dns server, you must specify the address of a dns server to resolve the domain name. You can write up to three addresses as the candidate dns server for the previous failure. "Domain zrs.com" specifies the default domain. File Content:

Domain 21php.com

Nameserver 11.0.0.1

4. The "named. boot" file is the configuration file used by the bind software of earlier versions. Now the new version has already been stored in "named. conf ". Named. conf is the core file of dns server configuration. The following is a piece of explanation.

# Named. conf-configuration for bind

#

# Generated automatically by bindconf, alchemist et al.

Controls {

Inet 127.0.0.1 allow {localhost;} keys {rndckey ;};

};

Include "/etc/rndc. key"; options {

Directory "/var/named /";

};

Zone "."{

Type hint;

File "named. ca ";

};

Zone "0.0.127.in-addr. arpa "{

Type master;

File "0.0.127.in-addr. arpa. zone ";

};

Zone "localhost "{

Type master;

File "localhost. zone ";

};

Zone "21php.com "{

Type master;

Optional Y yes;

File "21php.com ";

};

In the above Article, # Is the annotation symbol. The meanings of other lines are as follows:

Diretables/var/named

Specify that named reads DNS data files from the/var/named directory. You can specify and create this directory. All DNS data files are stored in this directory;

Zone "."{

Type hint;

File "named. ca ";

};

Specify named to obtain the top-level "root" server address of the Internet from the named. ca file.

Zone "0.0.127.in-addr. arpa "{

Type master;

File "0.0.127.in-addr. arpa. zone ";

};

Specify the named as the IP address range of 127.0.0 to the master server, named. 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 );

Zone "localhost "{

Type master;

File "localhost. zone ";

};

The DNS file data containing localhost is stored in/var/named/localhost. zone;

Zone "21php.com "{

Type master;

Optional Y yes;

File "21php.com. zone ";

};

The preceding statement indicates that DNS data in the domain 21php.com is stored in 21php.com. zone in the/var/named/directory;

You can use the text editor to open/var/named/21php.com. zone. The content is as follows:

$ TTL 86400 @ in soa @ root. localhost (

2; serial

28800; refresh

7200; retry

604800; expire

86400; ttl

)

@ In ns localhost

Www in a 11.0.0.233

Www2 in a 11.0.0.23

Forum in a 11.0.0.10

@ In mx 5 mail.21php.com.

The first part of the file is the corresponding parameter settings, this part does not need to be modified, and the subsequent part is the specific DNS data;

For example:

Www in a 11.0.0.233

Resolve www.21php.com to 11.0.0.233;

Www2 in a 11.0.0.23

Resolve www2.21php.com to 11.0.0.23;

Club in a 11.0.0.10

Resolve club.21php.com to 11.0.0.10;

③ Configure the secondary DNS Server

Configure the server 11.0.0.2 as the 21php.com secondary dns Server

The secondary DNS Server transfers a complete set of domain information from the primary server. Zone files are transferred from the master server and stored as local disk files on the secondary server. The secondary server has a complete copy of the domain information, so you can also query the domain. The configuration content of this part is as follows:

Zone "21php.com" IN {

Type slave;

File "21php.com. zone ";

Masters {11.0.0.1 ;};

};

As you can see, unlike the primary DNS server, "type" is changed to "slave", and then the address "masters {11.0.0.1 ;};" of the primary DNS server is specified ;};". When the DNS service is started, it automatically connects 11.0.0.1, reads information about the 21php.com domain, and saves it to the 21php.com. zone file on the local machine.

④ Test the DNS server

After modifying the corresponding DNS file, run the "ndc restart" command to restart the service. In redhat 7.1 or a later version, run the following command:

/Etc/rc. d/init. d/named restart

Or

/Etc/rc. d/init. d/named reload

Make the change take effect.

To test DNS, you can find a client and set its DNS address to a new DNS server address. Then, try surfing the Internet, receiving emails, downloading emails, and so on. You can also run the nslookup command: Run nslookup, enter the host name to be queried, and check whether the correct IP address is returned. We recommend that you use the dig command in redhat 7.1 or later versions.

Note: The above are tested in REDHAT 6.1 REDHAT 9 respectively.

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.