本文共 4322 字,大约阅读时间需要 14 分钟。
本教程实验环境:
[root@localhost ~]# cat /etc/redhat-release CentOS release 6.5 (Final)[root@localhost ~]#
[root@localhost ~]# vim /etc/named.rfc1912.zones
zone "zzqa.com" IN { type master; file "zzqa.com"; allow-update { none; };};zone "zzqb.com" IN { type master; file "zzqb.com"; allow-update { none; };};zone "zzqc.com" IN { type master; file "zzqc.com"; allow-update { none; };};
[root@localhost ~]# cd /var/www/html/[root@localhost html]# mkdir zzqa[root@localhost html]# mkdir zzqb[root@localhost html]# mkdir zzqc[root@localhost html]# ls1.html 1.php DVWA zzqa zzqb zzqc[root@localhost html]#
[root@localhost html]# echo "I am zzqa" > zzqa/index.html[root@localhost html]# echo "I am zzqb" > zzqb/index.html[root@localhost html]# echo "I am zzqc" > zzqc/index.html[root@localhost html]#
/var/named/
目录下面拷贝3份模板分别作为解析三个站点的配置文件。[root@localhost ~]# cd /var/named/[root@localhost named]# cp named.localhost zzqa.com[root@localhost named]# cp named.localhost zzqb.com[root@localhost named]# cp named.localhost zzqc.com
zzqa.com
zzqb.com
zzqc.com
三个解析文件,编辑完成,保存并退出。[root@localhost named]# vim zzqa.com
$TTL 1D@ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @@ IN A 192.168.3.112www IN A 192.168.3.113game IN A 10.1.1.1
[root@localhost named]# vim zzqb.com
$TTL 1D@ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @@ IN A 192.168.3.112www IN A 192.168.3.114game IN A 10.1.1.2
[root@localhost named]# vim zzqc.com
$TTL 1D@ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @@ IN A 192.168.3.112www IN A 192.168.3.115game IN A 10.1.1.3
[root@localhost named]# service named restart
重启服务没毛病,说明我们的dns解析配置没出错!
下面测试:
开始测试一下失败了,原因是三个目录没有给可读权限:
[root@localhost named]# ll | grep zzq[root@localhost named]# chmod +r zzq*[root@localhost named]# ll | grep zzq
[root@localhost named]# service named restart
[root@localhost ~]# ifconfig eth0:1 192.168.3.113 netmask 255.255.255.0[root@localhost ~]# ifconfig eth0:2 192.168.3.114 netmask 255.255.255.0[root@localhost ~]# ifconfig eth0:3 192.168.3.115 netmask 255.255.255.0
配置完之后查看一下:
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
ServerAdmin www.zzqa.com DocumentRoot /var/www/html/zzqa/ ServerName 192.168.3.113 ErrorLog logs/dummy-host.zzqa.com-error_log CustomLog logs/dummy-host.zzqa.com-access_log common ServerAdmin www.zzqb.com DocumentRoot /var/www/html/zzqb/ ServerName 192.168.3.114 ErrorLog logs/dummy-host.zzqb.com-error_log CustomLog logs/dummy-host.zzqb.com-access_log common ServerAdmin www.zzqc.com DocumentRoot /var/www/html/zzqc/ ServerName 192.168.3.115 ErrorLog logs/dummy-host.zzqc.com-error_log CustomLog logs/dummy-host.zzqc.com-access_log common
[root@localhost html]# service httpd restart
通过web访问三个站点,如下图所示:
没毛病,全部正常!
转载地址:http://lxsfa.baihongyu.com/