rpm -q bind //查询是否安装bind yum -y install bind vi /etc/named.conf 更改 any listen-on port 53 { any; }; allow-query { any; };
vi /etc/named.rfc1912.zones 增加域名: 正向 zone "cqipc18.edu." IN { type master; file "cqipc18.edu.zone"; allow-update { none; }; }; 反向 zone "118.16.172.in-addr.arpa" IN { type master; file "118.16.172.zone"; allow-update { none; }; };
cd /var/named cp -p named.localhost cqipc18.edu.zone vi cqipc18.edu.zone 正向 $TTL 1D @ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum @ NS dns.cqipc18.edu. dns A 172.16.118.118 www A 172.16.118.200 ftp A 172.16.118.201 mail A 172.16.118.202 @ MX 6 mail.cqipc18.edu. down CNAME ftp.cqipc18.edu. 反向 cp -p cqipc18.edu.zone 118.16.172.zone vi 118.16.172.zone $TTL 1D @ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum @ NS dns.cqipc18.edu. dns A 172.16.118.118 200 PTR www.cqipc18.edu. 201 PTR ftp.cqipc18.edu. 202 PTR mail.cqipc18.edu.
> set type=ptr //反向测试 > 172.16.118.200 Server: 127.0.0.1 Address: 127.0.0.1#53
200.118.16.172.in-addr.arpa name = www.cqipc18.edu. > //在这输入exit退出
HTTPD
1 2 3 4 5 6 7
1、根据自己的环境配置任意IP地址,但IP地址最后一段为自己的学号。 2、配置DNS服务器,要求添加两个区域“dayXX.net”和“nightXX.net”; 建立www. dayXX.net和www.nightXX.net地址记录指向本机IP。 3、使用apache来建立2个基于域名的虚拟主机站点:www.dayXX.net和www.nightXX.net, 根据配置的DNS服务,网站主目录分别是/html/dayXX和html/nightXX。 4.建立主页: www.dayXX.net主页内容为“this is dayXX.net’s web page”; www.nightXX.net主页内容为“this is nightXX.net’s web page”; 5、在WIN7用IE浏览器测试。
//下面是配置DNS服务器,添加两个区域,如果前面或者上课做过了的可以不用做 vi /etc/named.conf 两个any
vi /etc/named.rfc1912.zones //改主配置文件,添加day18.net和night18.net
zone "day18.net." IN { type master; file "day18.net.zone"; allow-update { none; }; };
zone "night18.net." IN { type master; file "night18.net.zone"; allow-update { none; }; };
cd /var/named cp -p named.localhost day18.net.zone vi day18.net.zone @ NS dns.day18.net. dns A 172.16.118.118 www A 172.16.118.118 cp -p day18.net.zone night18.net.zone vi night18.net.zone @ NS dns.night18.net. dns A 172.16.118.118 www A 172.16.118.118
//下面是使用apache来建立2个基于域名的虚拟主机站点 和建立主页 cd /var/www/html/ mkdir day18 vi day18/index.html this is day18.net's web page //写入内容 mkdir night18 vi night18/index.html this is night18.net's web page //写入内容 cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak //备份httpd.conf vi /etc/httpd/conf/httpd.conf: #ServerName www.example.com:80//把#去掉,www.example.com改为自己的IP地址,如下 #ServerName 172.16.118.118:80 //再添加如下内容 <VirtualHost 172.16.118.118> DocumentRoot /var/www/html/day18 ServerName www.day18.net </VirtualHost> <VirtualHost 172.16.118.118> DocumentRoot /var/www/html/night18 ServerName www.night18.net </VirtualHost>
systemctl restart httpd //重启HTTPD服务,这里要等待一回
测试 在win7中输入www.day18.net和www.night18.net测试 在Linux中测试输入 curl 172.16.118.118 [root@lai18 html]# curl 172.16.118.118 this is day18.net's web page