、服务题(一共2题,根据题目难易程度分值不同,考试环境:RHEL8虚拟机两台,一个脚本 net+yum. sh,防火墙为开启状态。04为自己的学号。 考试前期准备:将脚本放入其中一台虚拟机中(PC1),执行脚本,配置好以下环 HOST NAME: station04. hnkfdx. edu HOST IP: 192.168.102.04/24 (DNS 和WEB服务器) GATEWAY: 192.168.102.2 DOMAIN: hnkfdx. edue PC2: HOST NAME:lmy04. hnkfdx. edu HOST IP: 192.168.102.252 GATEWAY: 192.168.102.2 DNS:192.168.102.04 DOMAIN: hnkfdx. edut 1、在PC1上部署DNS服务,解析的域名为hnkfdx.edu;域中有5台主机,ip和 主机名如下表所示。 IP地址 192.168.102.04 192.168.102.201 192.168.102.202 192.168.102.203 192.168.102.252 主机名 station04. hnkfdx. edu Studentl. hnkfdx.edu Student2. hnkfdx.edu Student3. hnkfdx. edulmy04.hnkfdx.edue 2、在PC1上安装配置 WEB服务器,完成以下需求:( (1)搭建一个基于用户站点的网页,网页路径/home/lmy/puklic.html,要求所有人都可以访问到此网页。网页内容为“I am liminyang” (2)配置虚拟主机,此虚拟主机拥有三个网站:www.hnkfdx.edu、 station04. hnkfdx.edu 和lmy04.hnkfdx.edu。 ①www. hnkfdx.edu 设置 DocumentReet.为/var/www/html,网页内容为 “www. hnkfdx.edu"。 ②station04. hnkfdx.edu 设置 DocumentReet.为/satation04,网页内容为 “station04. hnkfdx. edu"。 ③lmy04. hnkfdx.edu设置 DocumentReet.为/var/www/web1,网页内容为 “lmy04.hnkfdx.edu”,采用8080端口进行访问。 ④虚拟主机配置完成后请在客户端使用网站名访问网页内容。 3、防火墙为开启状态,请将你做的服务添加至防火墙上,使其客户端能够访问。
时间: 2024-04-23 14:24:29 浏览: 8
1. 在PC1上部署DNS服务,解析的域名为hnkfdx.edu;域中有5台主机,ip和主机名如下表所示。
IP地址 主机名
192.168.102.04 station04.hnkfdx.edu
192.168.102.201 Student1.hnkfdx.edu
192.168.102.202 Student2.hnkfdx.edu
192.168.102.203 Student3.hnkfdx.edu
192.168.102.252 lmy04.hnkfdx.edu
在PC1上执行以下操作:
1) 安装bind软件包:`yum install bind -y`
2) 配置DNS服务:
a. 编辑主配置文件:`vi /etc/named.conf`,添加以下内容:
```
zone "hnkfdx.edu" IN {
type master;
file "hnkfdx.edu.zone";
allow-update { none; };
};
```
b. 编辑域名解析文件:`vi /var/named/hnkfdx.edu.zone`,添加以下内容:
```
$TTL 86400
@ IN SOA station04.hnkfdx.edu. root.hnkfdx.edu. (
2021102001 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
86400 ) ; Minimum TTL
;
IN NS station04.hnkfdx.edu.
IN A 192.168.102.04
Student1 IN A 192.168.102.201
Student2 IN A 192.168.102.202
Student3 IN A 192.168.102.203
lmy04 IN A 192.168.102.252
```
3) 启动并设置DNS服务开机自启:`systemctl start named && systemctl enable named`
4) 在PC2上将DNS服务器地址设置为192.168.102.04,测试域名解析是否成功:`ping Student1.hnkfdx.edu`
2. 在PC1上安装配置WEB服务器,完成以下需求:
(1)搭建一个基于用户站点的网页,网页路径为/home/lmy/public.html,要求所有人都可以访问到此网页。网页内容为“I am liminyang”
a. 安装httpd软件包:`yum install httpd -y`
b. 配置用户站点:`mkdir -p /home/lmy/public_html && echo "I am liminyang" > /home/lmy/public_html/index.html`
c. 修改httpd服务配置文件`/etc/httpd/conf/httpd.conf`,将以下两个指令去掉注释:
```
UserDir disabled
UserDir public_html
```
d. 启动并设置httpd服务开机自启:`systemctl start httpd && systemctl enable httpd`
e. 在客户端访问:`http://192.168.102.04/~lmy/`
(2)配置虚拟主机,此虚拟主机拥有三个网站:www.hnkfdx.edu、station04.hnkfdx.edu和lmy04.hnkfdx.edu。
a. 编辑httpd服务的配置文件`/etc/httpd/conf/httpd.conf`,添加以下内容:
```
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.hnkfdx.edu
DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName station04.hnkfdx.edu
DocumentRoot /station04
<Directory /station04>
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName lmy04.hnkfdx.edu
DocumentRoot /var/www/web1
<Directory /var/www/web1>
AllowOverride none
Require all granted
</Directory>
Listen 8080
</VirtualHost>
```
b. 创建网站文件夹并添加网页内容:
```
mkdir -p /var/www/html
echo "www.hnkfdx.edu" > /var/www/html/index.html
mkdir -p /station04
echo "station04.hnkfdx.edu" > /station04/index.html
mkdir -p /var/www/web1
echo "lmy04.hnkfdx.edu" > /var/www/web1/index.html
```
c. 启动httpd服务:`systemctl start httpd`
d. 在客户端访问:
- www.hnkfdx.edu:`http://192.168.102.04/`
- station04.hnkfdx.edu:`http://station04.hnkfdx.edu/`
- lmy04.hnkfdx.edu:`http://lmy04.hnkfdx.edu:8080/`
3. 防火墙为开启状态,请将你做的服务添加至防火墙上,使其客户端能够访问。
a. 添加http服务:`firewall-cmd --add-service=http --permanent`
b. 添加DNS服务:`firewall-cmd --add-service=dns --permanent`
c. 添加8080端口:`firewall-cmd --add-port=8080/tcp --permanent`
d. 重新加载防火墙规则:`firewall-cmd --reload`