1.安装DNS软件:bind-chroot bind
yum -y install bind-chroot bind
2.修改主配置文件
2.1修改前备份
cp -p /etc/named.conf /etc/named.bak
2.2修改配置
vim /etc/named.conf
options {
directory "/var/named";
};
zone "xiaoli.com" IN {
type master;
file "xiaoli.com.zone";
};
3.建立地址库文件
3.1修改前备份
cp -p /var/named/named.localhost /var/named/xiaoli.com.zone
3.2修改配置
vim /var/named/xiaoli.zone
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
xiaoli.com. NS www0
www0 A 192.168.162.133
vip0 A 192.168.162.133
4.重启DNS服务:named
systemctl restart named
查看防火墙是否设置允许所有
firewall-cmd --get-default-zone
public
设置防火墙允许所有
firewall-cmd --set-default-zone=trusted
success
firewall-cmd --get-default-zone
trusted
5.客户端验证DNS服务
在另一台机器上验证 1.指定DNS服务器
echo 'nameserver 192.168.162.133' > /etc/resolv.conf
nslookup
> www0.xiaoli.com
Server: 192.168.162.133
Address: 192.168.162.133
Name: www0.xiaoli.com
Address: 192.168.162.133
> vip0.xiaoli.com
Server: 192.168.162.133
Address: 192.168.162.133
Name: vip0.xiaoli.com
Address: 192.168.162.133
完。
6.添加网页指向域名
6.1.安装HTTP软件:httpd
yum -y install httpd
6.2.建立调用配置文件
主配置:/etc/httpd/conf/httpd.conf #一般不修改 调用配置:/etc/httpd/conf.d/
vim /etc/httpd/conf.d/xiaoli.com.conf
<VirtualHost *:80>
ServerName www0.xiaoli.com
DocumentRoot "/var/www/www0"
</VirtualHost>
<VirtualHost *:80>
ServerName vip0.xiaoli.com
DocumentRoot "/var/www/vip0"
</VirtualHost>
建立调用配置后,还要建立对应的目录文件 DocumentRoot “/var/www/www0” DocumentRoot “/var/www/vip0” 并编辑网页内容
6.3.建立网页目录及页面内容
mkdir /var/www/www0
mkdir /var/www/vip0
echo "I am WWW0" > /var/www/www0/index.html
echo "I am VIP0" > /var/www/vip0/index.html
6.4.重启httpd服务
systemctl restart httpd
7.客户端验证网页内容
|