标签:dns学习笔记
安装RPM包
[root@localhost extra]# rpm -qa | grep "^bind"
bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64 伪根 (可有可无)
主要:
bind-libs-9.8.2-0.17.rc1.el6_4.6.x86_64
bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64
bind-9.8.2-0.17.rc1.el6_4.6.x86_64
安装软件包
yum install -y bind bind-libs bind-utils
查看是否安装成功!
[root@localhost DNS]# rpm -qa | grep "^bind"
bind-libs-9.8.2-0.17.rc1.el6_4.6.x86_64
bind-9.8.2-0.17.rc1.el6_4.6.x86_64
bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64
查看DNS服务是否运行
[root@localhost DNS]# service named status(停止状态)
编辑配置文件 默认监听端口为 53
named服务的主配文件
vim /etc/named.conf
options {
directory "/var/named";
};
zone "benet.com" IN {
type master;
file "benet.com.zone";
};
zone "116.168.192.in-addr.arpa" IN {
type master;
file "192.168.116.zone";
};
zone "accp.com" IN {
type master;
file "accp.com.zone";
};
区域数据配置文件
cd /var/named
cp named.localhost benet.com.zone
vim benet.com.zone
配置如下
$TTL 86400
@ IN SOA benet.com. admin.benet.com. (
10 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS ns1.benet.com.
ns1 IN A 192.168.116.111
www IN A 192.168.116.111
~
cp benet.com.zone accp.com.zone
vim accp.com.zone
配置如下
$TTL 86400
@ IN SOA accp.com. accp.benet.com. (
10 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS ns1.accp.com.
ns1 IN A 192.168.116.111
www IN A 192.168.116.111
~
vim 192.168.116.zone
配置如下
$TTL 86400
@ IN SOA benet.com. admin.benet.com. (
10 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS ns1.benet.com.
111 IN PTR ns1.benet.com.
111 IN PTR www.benet.com.
111 IN PTR www.accp.com.
111 IN PTR ns1.accp.com.
设置权限
chmod 777 benet.com.zone
chmod 777 accp.com.zone
chmod 777 192.168.116.zone
重启named服务
service named start
测试成果
nslookup www.benet.com
nslookup 192.168.116.111
nslookup www.accp.com
·基于域名的Apache虚拟主机
准备目录和文件
mkdir -p /var/www/html/benetcom
mkdir -p /var/www/html/accpcom
echo "benet.com" > /var/www/html/benetcom/index.html && echo "accp.com" > /var/www/html/accpcom/index.html
修改虚拟主机配置文件--配置虚拟主机
vim /usr/local/httpd/conf/extra/httpd-vhosts.conf 虚拟主机主配文件
配置内容
目录权限(允许所有主机访问)
<Directory "/var/www/html">
Order allow,deny
Allow from all
</Directory>
NameVirtualHost 192.168.116.111
<VirtualHost 192.168.116.111>
DocumentRoot "/var/www/html/benetcom"
ServerName www.benet.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost 192.168.116.111>
DocumentRoot "/var/www/html/accpcom"
ServerName www.accp.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
修改apache的主配置文件
vim /usr/local/httpd/conf/httpd.conf
在配置完虚拟主机后将这个文件包含进去
387 # Virtual hosts
388 Include conf/extra/httpd-vhosts.conf
在浏览器中分别访问
所出现的页面不一样 成功!!!
本文出自 “浅笑习惯囿你” 博客,谢绝转载!
标签:dns学习笔记
原文地址:http://1339329314.blog.51cto.com/10122825/1704622