创建一个DNS缓存域名服务器

关闭服务器防火墙,关闭服务器保护机制

[root@localhost ~]# iptables -F
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0

确定服务器可以上网

[root@localhost ~]# ping www.baidu.com

安装bind bind-libs bind-utils软件

 [root@localhost ~]# yum -y install bind bind-libs bind-utils
 
[root@localhost ~]# rpm -qa | grep ^bind
bind-utils-9.9.4-61.el7.x86_64
bind-libs-9.9.4-61.el7.x86_64
bind-9.9.4-61.el7.x86_64

备份下,避免出现错误

[root@localhost ~]# cp /etc/named.conf /etc/named.conf.bak

方法一:在顶级域名查找(服务器ip192.168.200.21),如果要配置DNS主源服务器则采用这个

[root@localhost ~]# vim /etc/named.conf
options {
     
	listen-on port 53 {
      192.168.200.21; }; 监控端口和地址
	directory 	"/var/named";  文件存放位置
	dump-file 	"/var/named/data/cache_dump.db";
	statistics-file "/var/named/data/named_stats.txt";
	memstatistics-file "/var/named/data/named_mem_stats.txt";
	allow-query    {
      192.168.200.0/24; };允许使用的本DNS网段
	recursion yes;
};
zone "." IN {
        向 顶级域. 的区域
	type hint; 类型
	file "named.ca"; 
};

[root@localhost ~]# ls -l /var/named/named.ca 
-rw-r----- 1 root named 2281 522 2017 /var/named/named.ca

[root@localhost ~]# named-checkconf /etc/named.conf
[root@localhost ~]# systemctl start named

方法二:在当地的较进的缓存域名查找:

[root@localhost ~]# vim /etc/named.conf
options {
     
	listen-on port 53 {
      192.168.200.21; };
	directory 	"/var/named";
	dump-file 	"/var/named/data/cache_dump.db";
	statistics-file "/var/named/data/named_stats.txt";
	memstatistics-file "/var/named/data/named_mem_stats.txt";
	allow-query     {
      192.168.200.0/24; };
	recursion yes;
	forwarders {
      202.102.128.68; };(山东菏泽联通DNS)
};

[root@localhost ~]# named-checkconf /etc/named.conf
[root@localhost ~]# systemctl start named

你可能感兴趣的:(linux服务,linux)