Build DNS under CentOS7
DNS (Domain Name System) is a distributed database that maps Domain names and IP addresses on the Internet, allowing users to access the Internet more conveniently. The process of obtaining the IP address corresponding to the host name through the host name is called domain name resolution (or host name resolution ). The DNS runs on the UDP protocol and uses the port number 53.
Next we will start to build DNS under CentOS7 for your reference only!
Note: This article only introduces the chroot mode. We will not introduce the non-chroot mode!
Environment preparation:
1. A CentOS7 Machine
2. IP Address: 192.168.0.254
3. Host Name: server.example.com
Start building DNS
1. install the software package
# Yum install bind-chroot bind-utils-y
2. Start configuration (after the chroot package is installed, all DNS-related files are in the/var/named/chroot/directory)
# Cd/var/named/chroot/
# Cp/etc/named. conf ./
# Chgrp named. conf
# Vim named. conf
Options {
Listen-on port 53 {any ;};
Directory "/var/named ";
};
Zone "." IN {
Type hint;
File "named. ca ";
};
Zone "example.com." IN {
Type master;
File "example.com. zone ";
};
Zone "0.168.192.IN-addr. arpa." IN {
Type master;
File "192.168.0.zone ";
};
# Cd ../var/named/
# Cp/var/named. ca ./
# Vim example.com. zone
$ TTL 600
@ In soa ns1.example.com. admin.example.com .{
20150106
1 H
5 M
2D
6 H)
In ns ns1
In mx 10 mail
Ns1 in a 192.168.0.1
Mail in a 192.168.0.2
Www in a 192.168.0.3
# Vim 192.168.0.zone
$ TTL 600
@ In soa ns1.example.com. admin.example.com .{
2014122322
1 H
5 M
2D
6 H)
In ns ns1.example.com.
1 in ptr ns1.example.com.
2 in ptr mail.example.com.
3 in ptr www.example.com.
# Chgrp named *
3. Start the bind Service
# Systemctl enable named-chroot-setup
# Systemctl restart named-chroot
4. Test
# Vim/etc/resolv. conf
Nameserver 192.168.0.254
Search example.com
# Nslookupwww.example.com
# Nslookup 192.168.0.1
Summary: by now, a basic DNS resolution has been completed, and other configurations about DNS forwarding, subdomain authorization, and view will be added one after another!