Configuring DNS in linux is a required part of Linux management. I always want to learn it, but I am too lazy to read the article. I recently used it in my work, so I started to learn it, after reading the article by laruence, I still couldn't understand it. I found N pieces of information on the Internet, no matter what I used, and finally found a simple configuration. Now I will record the configuration to facilitate future query.
RHEL5 getting started with configuring DNS
Note: The bind I use is the built-in version of the CD. If you use yum or download it online, we recommend that you delete it and install it on the CD.
Objective: My machine IP address is 192.168.100.252 and my domain name is baidu.org.tw. I want to resolve www.baidu.org.tw and mail.baidu.org.tw to the IP address 192.168.100.252.
Note: Use the TAB key for the "space" below
Steps:
1. Create a new file named. conf in the directory/var/named/chroot/etc (you do not need to create it if you have it)
2. Write the following content in the named. conf file:
Options
{
Directory "/var/named ";
};
Zone "."
{
Type hint;
File "named. ca ";
};
---------- Briefly explain what the above content means ---------------
Options is used to describe global attributes, where directory is the working directory of the specified DNS server.
Add an analytic file named "." pointing to a root domain.
3. to generate a named. ca file, configure an available DNS:
Echo "nameserver 61.177.7.1">/etc/resolv. conf (61.177.7.1 is a DNS server in Suzhou and changed to your available DNS server)
4. Then use the command to create named. ca:
Dig-t NS.>/var/named/chroot/var/named. ca
5. Now you can start the DNS server. The command is as follows:
Service named start
-----------------------------------------
To test whether it is successful, you can change your DNS to 127.0.0.1, and then check whether the Internet is available, or use another machine to change the DNS to the IP address of the machine to see if it can be resolved.
6. After completing the configuration, you can configure our domain. Add the corresponding forward and reverse resolution in named. conf and change it to the following:
Options
{
Directory "/var/named ";
};
Zone "."
{
Type hint;
File "named. ca ";
};
Zone "baidu.org.tw" # Add a baidu.org.tw Region
{
Type master;
File "baidu.org.tw. zone"; # point the parsing file to baidu.org.tw. zone.
};
Zone "100.168.192.in-addr. arpa" # This performs reverse resolution because my IP address is 192.168.100.
{
Type master;
File "192.168.100.rev"; # reverse parsing file pointing
};
7. After adding the forward and reverse directions, add the corresponding parsing file/var/named/chroot/var/named/baidu.org.tw. zone. The content is as follows:
@ In soa baidu.org.tw. root (
20090803
1 H
15 M
1 W
1D)
In ns ns
In mx 10 mail
Ns in a 192.168.100.252 # Use the record to point all ns, www, and mail records to 192.168.100.252.
Www in a 192.168.100.252
Mail in a 192.168.100.252
8. Add this file record/var/named/chroot/var/named/192.168.100.rev. The content is as follows:
@ In soa baidu.org.tw. root (
20090803
1 H
15 M
1 W
1D)
In ns ns.baidu.org.tw.
113 in ptr ns.baidu.org.tw.
113 in ptr www.baidu.org.tw.
113 in ptr mail.baidu.org.tw.
9. Run the command to restart the DNS server service named restart and then parse it. Ping www.baidu.org.tw and point to 192.168.100.252.