环境:
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.安装服务----------------
[[email protected] ~]# yum install -y bind bind-utils //安装DNS服务与nslookup命令
[[email protected] ~]# systemctl stop firewalld //关闭防火墙
[[email protected] ~]# setenforce 0 //关闭selinux
-------------2.编辑主配置文件---------------
[[email protected] ~]# 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";
};
保存退出
[[email protected] ~]# named-checkconf //检查语法错误
---------------3.编辑区域配置文件----------------
[[email protected] ~]# vi /etc/named.rfc1912.zones
zone开头的全部删掉(或者每个上面添加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";
};
};
保存退出
[[email protected] ~]# named-checkconf //检查语法错误
----------4.编辑区域数据配置文件------------
[[email protected] ~]# cd /var/named
[[email protected] named]# cp -p named.localhost hello.com.zone.lan //创建内网区域数据配置文件
[[email protected] named]# cp -p named.localhost hello.com.zone.wan //创建外网区域数据配置文件
[[email protected] named]# vi hello.com.zone.lan //编辑内网区域数据配置文件
修改如下配置:
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.80.180 //本机地址
www IN A 192.168.80.180 //www.hello.com对应的地址
保存退出
[[email protected] named]# vi hello.com.zone.wan //编辑外网区域数据配置文件
修改如下配置:
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.90.180 //本机地址
www IN A 192.168.90.180 //www.hello.com对应的地址
保存退出
[[email protected] named]# named-checkconf //检查语法
----------5.启动服务----------------
[[email protected] named]# systemctl start named //启动DNS服务
[[email protected] named]# netstat -anpu | grep named //查看DNS服务状态
显示如图:
第二步:客户端测试
---------1.linux客户端测试-----------
[[email protected] ~]# systemctl stop firewalld //关闭防火墙
[[email protected] ~]# setenforce 0 //关闭selinux
[[email protected] ~]# vi /etc/resolv.conf //配置dns
添加域名:(其它都删除)
nameserver 192.168.80.180
保存退出
[[email protected] ~]# nslookup www.hello.com //解析www.hello.com
//成功解析
---------2.win7客户端测试----------
//关闭防火墙
//添加DNS为192.168.90.180,如图:
//解析www.hello.com,如图:
//解析成功
原文地址:http://blog.51cto.com/12227558/2060351