Centos7 builds a complete version of DNS service

dns service: It is a domain name resolution service. Its function is to resolve domain names into IP addresses, or to resolve IP addresses into domain names.
Experimental environment: centos 7 192.168.80.150
win7 client 192.168.80.1
The premise is that they must be in the same environment< /span>
The first step is to turn off the firewall and selinux features, and then install the service

yum -y install bind

Temporarily turn off the firewall

systemctl stop firewalld
永久关闭防火墙
systemctl disable firewalld

Temporarily turn off selinux features

setenforce 0

To permanently shut down selinux, first enter the configuration file vim /etc/selinux/config

Insert image description here
Just set SELINUX=disabled above, save and exit wq

The second step is to enter the dns configuration file and configure vim /etc/named.conf

Insert image description here
listen-on port 53 {192.168.80.150;}; Set it to the local IP address.
allow-query {any;} is set to be accessible to everyone.

The third step is to enter the vim /etc/named.rfc1912.zones configuration file and configure it. pip.cc is the domain name I want to set, and 80.168.192 is the network segment I set. The file name can be based on your needs. and must correspond one-to-one with the configuration file of the /var/named/ file

Insert image description here

The fourth step is to use touch in the cd /var/named/ directory to create two files that correspond to the above files one-to-one. Then use the template file named.localhost to overwrite the file just created.

Insert image description here
Note that after creating the above, you need to use chown root:named zheng and fan to change the file permissions.

Insert image description here

Step 5, then go into the A file you created

Insert image description here

@dns.pip.cc. is your host name plus domain name (pay attention to the details of cc.)
Then add the host record
NS dns.pip.cc. The domain name of this machine
dns A 192.168.80.150 dns is the domain name of pip.cc, corresponding to 192.168.80.150
www A 192.168.80.170 www is the domain name of pip.cc, corresponding to 192.168.80.170
ftp A 192.168.80.180 ftp is the domain name of pip.cc, corresponding to 192.168.80.180 a>
Save and exit after writing

Step 6: Edit the PTR file

Insert image description here

Just write it backwards as above, the principle is the same.

Step 7: Restart the service

systemctl restart named

Then use the client to enter nslookup to access it.

Insert image description here

Guess you like

Origin blog.csdn.net/qq_51235445/article/details/124898262