This article is first published 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
650) This. width = 650; "Title =" clip_image001 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image001 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105988flb1.png "width =" 664 "Height =" 247 "/>
650) This. width = 650; "Title =" clip_image002 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image002 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105988sgnY.png "width =" 642 "Height =" 189 "/>
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
650) This. width = 650; "Title =" clip_image003 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image003 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105988N6wS.png "width =" 621 "Height =" 282 "/>
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/
650) This. width = 650; "Title =" clip_image004 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image004 "src =" http://img1.51cto.com/attachment/201408/27/526870_14091059897eTV.png "width =" 1023 "Height =" 203 "/>
CP-RV/usr/share/doc/bind-9.8.2/sample/etc/*/var/named/chroot/etc/
650) This. width = 650; "Title =" clip_image005 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image005 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105989028i.png "width =" 775 "Height =" 98 "/>
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
650) This. width = 650; "Title =" clip_image006 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image006 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105990xhhR.png "width =" 578 "Height =" 536 "/>
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:
650) This. width = 650; "Title =" clip_image007 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image007 "src =" http://img1.51cto.com/attachment/201408/27/526870_14091059904K4o.png "width =" 589 "Height =" 459 "/>
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:
650) This. width = 650; "Title =" clip_image008 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image008 "src =" http://img1.51cto.com/attachment/201408/27/526870_14091059900baG.png "width =" 580 "Height =" 531 "/>
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:
650) This. width = 650; "Title =" clip_image009 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image009 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105991jCML.png "width =" 479 "Height =" 409 "/>
Copy the named. localhost file and rename it ilanni.com. Zone as follows:
CP named. localhost ilanni.com. Zone
650) This. width = 650; "Title =" clip_image010 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image010 "src =" http://img1.51cto.com/attachment/201408/27/526870_14091059912M9S.png "width =" 478 "Height =" 65 "/>
Now, edit the ilanni.com. Zone file and add relevant address resolution to it. As follows:
VI ilanni.com. Zone
650) This. width = 650; "Title =" clip_image011 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image011 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105991rHSc.png "width =" 458 "Height =" 253 "/>
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:
650) This. width = 650; "Title =" clip_image012 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image012 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105992o76j.png "width =" 447 "Height =" 237 "/>
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:
650) This. width = 650; "Title =" clip_image013 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image013 "src =" http://img1.51cto.com/attachment/201408/27/526870_14091059920fur.png "width =" 535 "Height =" 183 "/>
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:
650) This. width = 650; "Title =" clip_image014 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image014 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105993VD7Y.png "width =" 402 "Height =" 333 "/>
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:
650) This. width = 650; "Title =" clip_image015 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image015 "src =" http://img1.51cto.com/attachment/201408/27/526870_14091059933MwZ.png "width =" 709 "Height =" 390 "/>
Run the NSLookup command to test the function:
650) This. width = 650; "Title =" clip_image016 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image016 "src =" http://img1.51cto.com/attachment/201408/27/526870_14091059933zrQ.png "width =" 456 "Height =" 261 "/>
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
650) This. width = 650; "Title =" clip_image017 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image017 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105994zLV1.png "width =" 396 "Height =" 127 "/>
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
650) This. width = 650; "Title =" clip_image018 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image018 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105994uvbQ.png "width =" 670 "Height =" 409 "/>
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
650) This. width = 650; "Title =" clip_image019 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image019 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105995aTeY.png "width =" 730 "Height =" 467 "/>
Dig-t a ftp.ilanni.com
650) This. width = 650; "Title =" clip_image020 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image020 "src =" http://img1.51cto.com/attachment/201408/27/526870_14091059953mbY.png "width =" 726 "Height =" 413 "/>
Now we can access the web server that has been built on 10.5.5.3 through the most practical results, as shown below:
650) This. width = 650; "Title =" clip_image021 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image021 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105996rcjV.png "width =" 1098 "Height =" 402 "/>
650) This. width = 650; "Title =" clip_image022 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image022 "src =" http://img1.51cto.com/attachment/201408/27/526870_1409105996DEnG.png "width =" 707 "Height =" 573 "/>
By now, DNS installation and simple configuration for centos have all been completed.
This article from the "muddy world" blog, please be sure to keep this source http://ilanni.blog.51cto.com/526870/1545510
Rotten mud: install and configure the DNS server in centos