Rotten mud: install and configure the DNS server in centos

Source: Internet
Author: User
Tags domain server nslookup command

This article was sponsored by Xiuyi linfeng and first launched in the dark world.

To configure the DNS server in centos, you must first install the DNS software bind. Of course, we can also install other DNS software, such as the domestic open source DNS software dnspod.

Here we use the DNS software bind as an example to conduct an experiment.

This experiment: OS centos6.5 64bit

Run the following command to install the DNS software:

Yum-y install bind-chroot bind-utils

The BIND configuration file is stored in two main locations:

/Etc/named. conf is the main configuration file of the bind service.

/Var/named/This is the zone file used to store DNS

If bind-chroot is installed, bind will be encapsulated into a pseudo root directory, and the original configuration file location will change:

/Var/named/etc/named. conf and/var/named/

Chroot encapsulates related files in a pseudo root directory for security protection. Once this program is cracked, you can only access the contents in the pseudo root directory, rather than the real root directory.

After the BIND has been installed, the configuration file content is blank. We can use the BIND help document for configuration. Because there are many BIND configuration parameters, we strongly recommend that you configure it on the basis of the help document through the template provided by BIND. View the BIND configuration as follows:

Rpm-QL bind | tac

Copy the files in the/usr/share/doc/bind-9.8.2/sample/var/and/usr/share/doc/bind-9.8.2/sample/etc/directories respectively, go to the/var/named/chroot/var/AND/var/named/chroot/etc/directories, as shown below:

CP-RV/usr/share/doc/bind-9.8.2/sample/var/*/var/named/chroot/var/

CP-RV/usr/share/doc/bind-9.8.2/sample/etc/*/var/named/chroot/etc/

After the configuration template is copied, modify the BIND master configuration file/var/named/chroot/etc/named. conf as follows:

VI/var/named/chroot/etc/named. conf

We will find that there are many options in this configuration file. For the simplicity of the experiment, we delete other functions that are not needed for the moment and only retain the most basic functions of BIND. As follows:

This file is retained only. The BIND working directory is/var/named/, and the port and IP address of the BIND listener are specified.

We have configured the BIND configuration file above. If we only follow the above operations, our DNS will not work properly yet. Because no related domain is created, we will create a primary domain server.

First, add a definition of the primary domain in the BIND configuration file. As follows:

Zone "ilanni.com "{

Type master;

File "ilanni.com. Zone ";

};

Zone "ilanni.com" defines the ilanni.com domain

Type master; defines the domain as the main domain service

File "ilanni.com. Zone" defines the zone file in the/var/named/chroot/var/named/directory.

Now let's create a zone file in the ilanni.com domain. By default, the BIND does not generate this file. We need to add it manually, but we mentioned that the BIND configuration file is complicated, therefore, we recommend that you use the template file named provided by BIND. localhost. As follows:

Copy the named. localhost file and rename it ilanni.com. Zone as follows:

CP named. localhost ilanni.com. Zone

Now, edit the ilanni.com. Zone file and add relevant address resolution to it. As follows:

VI ilanni.com. Zone

We only need to add a new resource record at the end of the file,A resource record is generally composed of four parts. The first part is the host name, the second part is the type, and the third part is the classification, where a represents the IPv4 address, and the fourth part represents the IP address.

Note that three resource records are added here. The first is the mail resource record. The mail resource record must be written in the front of other resource records, and the mail resource record is in the form of a domain name, and there is a last point behind the domain name.

In this case, our ilanni.com. after the zone file has been configured, we will check the/var/named/chroot/var/named directory. All file attributes must have readable attributes. As follows:

After all the above configurations are complete, we can start the bind. Run the following command:

/Etc/init. d/named start

If the BIND has been started, we can use the/etc/init. d/named reload command to reload the configuration file. As follows:

Since this machine has already set up a DHCP server, we can modify the DNS address obtained by the client through The Dhcp Service as follows:

10.5.5.1 is the IP address of the local machine.

Now let's take a look at the IP address obtained by the client, as shown below:

Run the NSLookup command to test the function:

Run the host command to test the IP addresses of www.ilanni.com and ftp.ilanni.com, as shown below:

Host www.ilanni.com

Host ftp.ilanni.com

We can see that www.ilanni.com and ftp.ilanni.com have been resolved. This is the same as the configuration on bind.

Run the dig command to test the IP address of the email server, as shown below:

Dig-t mx ilanni.com

We can see that the email server has been correctly resolved to 10.5.5.3.

You can also use the dig command to test the WWW and FTP resolution, as shown below:

Dig-t a www.ilanni.com

Dig-t a ftp.ilanni.com

Now we can access the web server that has been built on 10.5.5.3 through the most practical results, as shown below:

By now, DNS installation and simple configuration for centos have all been completed.

Rotten mud: install and configure the DNS server in centos

Related Article

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.