RHCE-DNS实验

底层:两台linux主机

[root@cilent ~]# mount /dev/sr0 /mnt   #挂载
[root@cilent ~]# yum install bind -y	#下载dns服务
[root@cilent ~]# systemctl stop firewalld	#关闭防火墙
[root@cilent ~]# senforce 0 	#关闭selinux
[root@cilent ~]# vim /etc/named.conf	#编辑主配置文件(删掉了一部分不必要的内容)
options {
        listen-on port 53 { 192.168.231.131; };
        directory       "/var/named";
        allow-query     { any; };
};

zone "qq.com" IN {
        type master;
        file "named.qq.com";
};

[root@cilent named]# cp named.localhost  named.qq.com	#复制并起名一个为qq.com的配置文件
[root@cilent named]# vim /var/named/named.qq.com	#编译子配置文件
$TTL 1D
@       IN SOA  @ rname.invalid. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      dns.qq.com.
www     IN      A       192.168.231.100
dns     IN      A       192.168.231.131

[root@cilent named]# systemctl restart named	#重启服务
[root@cilent named]# systemctl status named		#查看服务状态
[root@cilent named]# nslookup	#测试
> server 192.168.231.131
Default server: 192.168.231.131
Address: 192.168.231.131#53
> www.qq.com
Server:		192.168.231.131
Address:	192.168.231.131#53
Name:	www.qq.com
Address: 192.168.231.100
[root@cilent named]# vim /etc/named.conf	#编译两条dns互联规则(小心编译规范)
options {
        listen-on port 53 { 192.168.231.131; };
        directory       "/var/named";
        allow-query     { any; };
};
        acl "china" { 192.168.231.131 ;};
        acl "america" { 192.168.231.133 ;};
        view "china"
{       match-clients { "china"; };


zone "qq.com" IN {
        type master;
        file "named.qq.com";
        notify yes;
};
};
        view "america"
{       match-clients { "america"; };

zone "qq.com" IN {
        type master;
        file "named.qq1.com";
        notify yes;
};
};
[root@cilent named]# cd /var/named
[root@cilent named]# ls
data             named.ca     named.localhost  slaves
dynamic          named.conf   named.loopback
named.baidu.com  named.empty  named.qq.com
[root@cilent named]# cp named.qq.com named.qq1.com	 #复制并起名为qq1.com的配置文件
[root@cilent named]# vim named.qq1.com 		#将其主机ip修改为192.168.231.50(便于区分)
[root@cilent named]# systemctl restart named		#重启服务
[root@cilent named]# nslookup		#测试
> server 192.168.231.131
Default server: 192.168.231.131
Address: 192.168.231.131#53
> www.qq.com 
Server:		192.168.231.131
Address:	192.168.231.131#53
Name:	www.qq.com
Address: 192.168.231.100
另一台主机:
[root@server ~]# nslookup		#测试
> server 192.168.231.131 
Default server: 192.168.231.131
Address: 192.168.231.131#53
> www.qq.com   
Server:		192.168.231.131
Address:	192.168.231.131#53

Name:	www.qq.com
Address: 192.168.231.50
> 
实验完毕!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

李昕泽不是程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值