环境:Linux服务器一台(双网卡)内网IP:192.168.80.180 外网IP:192.168.90.180 Linux客户端一台,IP地址:192.168.80.10 Win7客户端一台,IP地址:192.168.90.10 保证服务器与两个客户端之间网络互通,如图://服务器测试//linux客户端测试//win7客户端测试
第一步:服务器配置--------------1.安装服务----------------[root@localhost ~]# yum install -y bind bind-utils //安装DNS服务与nslookup命令[root@localhost ~]# systemctl stop firewalld //关闭防火墙[root@localhost ~]# setenforce 0 //关闭selinux-------------2.编辑主配置文件---------------[root@localhost ~]# vi /etc/named.conf ……………options {listen-on port 53 { any; }; //监听服务器上所有地址listen-on-v6 port 53 { ::1; };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 { any; }; //允许所有人访问跳到52行,将下面四行删掉(zone开头的删掉)zone "." IN {type hint;file "named.ca";};保存退出[root@localhost ~]# named-checkconf //检查语法错误---------------3.编辑区域配置文件----------------[root@localhost ~]# vi /etc/named.rfc1912.zoneszone开头的全部删掉(或者每个上面添加view配置)添加以下内容:view "LAN" { //配置内网match-clients { 192.168.80.0/24; };zone "hello.com" IN {type master;file "hello.com.zone.lan"; };};view "WAN" { //配置外网match-clients { any; };zone "hello.com" IN {type master;file "hello.com.zone.wan";};};保存退出[root@localhost ~]# named-checkconf //检查语法错误----------4.编辑区域数据配置文件------------[root@localhost ~]# cd /var/named [root@localhost named]# cp -p named.localhost hello.com.zone.lan //创建内网区域数据配置文件[root@localhost named]# cp -p named.localhost hello.com.zone.wan //创建外网区域数据配置文件[root@localhost named]# vi hello.com.zone.lan //编辑内网区域数据配置文件 修改如下配置:$TTL 1D@ IN SOA @ rname.invalid. (0 ; serial1D ; refresh1H ; retry1W ; expire3H ) ; minimumNS @A 192.168.80.180 //本机地址www IN A 192.168.80.180 //www.hello.com对应的地址保存退出[root@localhost named]# vi hello.com.zone.wan //编辑外网区域数据配置文件修改如下配置:$TTL 1D@ IN SOA @ rname.invalid. (0 ; serial1D ; refresh1H ; retry1W ; expire3H ) ; minimumNS @A 192.168.90.180 //本机地址www IN A 192.168.90.180 //www.hello.com对应的地址保存退出[root@localhost named]# named-checkconf //检查语法----------5.启动服务----------------[root@localhost named]# systemctl start named //启动DNS服务[root@localhost named]# netstat -anpu | grep named //查看DNS服务状态显示如图:
第二步:客户端测试---------1.linux客户端测试-----------[root@localhost ~]# systemctl stop firewalld //关闭防火墙[root@localhost ~]# setenforce 0 //关闭selinux[root@localhost ~]# vi /etc/resolv.conf //配置dns添加域名:(其它都删除)nameserver 192.168.80.180保存退出[root@localhost ~]# nslookup www.hello.com //解析www.hello.com//成功解析---------2.win7客户端测试----------//关闭防火墙//添加DNS为192.168.90.180,如图://解析www.hello.com,如图://解析成功
转载于:https://blog.51cto.com/12227558/2060351