Establish a complete DNS server

DNS server role and principles

DNS is on the Internet domain name resolves to the IP address of the corresponding server, storage information corresponding to all IP and domain name on the Internet, then we will visit URLs into IP addresses and return, and then go to the computer by IP address access server, access to data.

We must first talk about the domain name, and here I take Baidu's address to explain:
www.baidu.com.

Complete domain name, followed all have a ".", But generally use is omitted, the default point, which is a full domain name. . "" By dividing into three parts:

www: www is the host name

baidu: baidu Shi area name

com: com is the type of

But usually, we used to type the whole name + together become the domain name, host name, called the subdomain. In fact not the case. Strictly speaking, that is 主机名, 域名, 类型.

Then, when we visited www.baidu.com, the computer looks for the corresponding URL to go to the dns server ipand back. This process is known DNS解析. The DNS server is divided into the following categories:

. "":. "" The last full URL that represents the root DNS server, DNS server root server is the highest-level server, distributed around the world. Which holds all types of DNS server IP addresses in the region

com: com is a DNS type, like the common com, net, org, edu, gov is a formal type of government regulation, as well as the common commercial types. Inside are preserved type the IP address of the domain name server com.

baidu.com:baidu domain name is com subordinate dns server, which holds the domain name to the IP addresses of all hosts baidu.com corresponding

When we visit www.baidu.com, looks com address all types of servers to go to the root servers, and then locate the server addresses of all domain names go on baidu.com com type of server, and finally go all baidu.com www.baidu.com this web site to find the corresponding IP address on the domain name server, and then returned to the host computer to access www.baidu.com. The host then establishes a connection with the IP server.

In addition, all these different levels of DNS servers are typically served by multiple servers at the same time, do a good redundancy is available, load balancing. In it are divided into:

Master: also known as master server, parsed from all other domain name server and cache server information is crawling on the master server down, all changes directly modify the line on the master, the other automatically synchronized

From the server: also known as slave server is redundant as the master server after failure to make master, slave can continue to provide services.

Cache Server: The main role is to cache DNS information, providing services to user queries, and can not configure a custom domain name for resolution.

Then again, when querying the DNS server, the query is divided into two modes, recursive queries, and query cycle:

Recursive queries: When you gonna go to a dns server to query results, the results will be returned to the inquirer, the inquirer query other DNS server again, this query returns again and again, until you find the data.

Cyclic query: cyclic query is to query a DNS server like those initiated after the inquiry by the DNS server to query other servers A, A went to query other servers B, until you find the results, and then return to B, B back to A, A then returned to the inquirer.

Under normal circumstances, our personal host, the configuration of our network configuration to the DNS server query, the query using a loop, instead we use a recursive query to get the query results on the network by the specified DNS server. Then returned to the individual user host. This is the working principle of the DNS server.

Build a complete DNS server

Preparing the Environment

  • Master
    • CentOS 7
    • 192.168.150.174
  • Slave
    • CentOS 7
    • 192.168.150.168
  • Test
    • Windows server 2008 R2 (testing machine)
    • 192.168.150.

Set up DNS-Master

  • Close SeLinuxandfirewalld
[root@dns-master ~]# service firewalld stop
Redirecting to /bin/systemctl stop  firewalld.service
[root@dns-master ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@dns-master ~]# firewall-cmd --state
not running
[root@dns-master ~]# setenforce 0
  • Installation bindandbind-chroot
[root@dns-master Packages]# rpm -ivh bind-9.9.4-37.el7.x86_64.rpm bind-libs-9.9.4-37.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:bind-libs-32:9.9.4-37.el7        ################################# [ 50%]
   2:bind-32:9.9.4-37.el7             ################################# [100%]
[root@dns-master Packages]# rpm -ivh bind-chroot-9.9.4-37.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:bind-chroot-32:9.9.4-37.el7      ################################# [100%]
  • Modify the configuration file, in order to better understand, so we own New Profile
[root@dns-master etc]# mv named.conf1 named.conf.bak ; touch named.conf
  • Modify the new named.confcontent follows
options {
directory "/var/named";
};
zone "quail.com" {
type master;
file "quail.com.zone";
};

  • Edit DNS database file /var/named/quail.com.zone
[root@dns-master etc]# [root@dns-master etc]# cat /var/named/quail.com.zone
$TTL 7200
quail.com. IN SOA quail.com. root.quail.com. (2020040800 1H 15M 1W 1D)
quail.com. IN NS www.quail.com.
www.quail.com. IN A 192.168.150.174
  • Restart the DNS service
[root@dns-master etc]# service named restart
Redirecting to /bin/systemctl restart  named.service
  • Test the forward zone

Because I was the youngest of the installation, you need to install it

[root@dns-master Packages]# rpm -ivh bind-utils-9.9.4-37.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:bind-utils-32:9.9.4-37.el7       ################################# [100%]
[root@dns-master Packages]# nslookup www.quail.com
Server:         192.168.150.174
Address:        192.168.150.174#53

Name:   www.quail.com
Address: 192.168.150.174

Set up DNS-Slave

  • Installation bindandbind-chroot
  • Modify the configuration filevim /etc/named.conf
options {
directory "/var/named";
};
zone "quail.com" IN {
type slave;
file "slaves/quail.com.zone";
masters { 192.168.150.174; };
allow-notify { 192.168.150.174; };
};

  • Restartnamed.service
[root@dns-slave slaves]# systemctl restart named
  • Check whether the normal synchronization
[root@dns-slave slaves]# ll
total 4
-rw-r--r-- 1 named named 193 Apr  8 19:30 quail.com.zone
  • See if you can successfully parsed
[root@dns-slave slaves]# nslookup
> www.quail.com
Server:         192.168.150.168
Address:        192.168.150.168#53

Name:   www.quail.com
Address: 192.168.150.174

So far, DNS set up is completed from the main system.

Guess you like

Origin www.cnblogs.com/quail2333/p/12659957.html