实验6 DNS服务器
一、实验目的
熟练掌握DNS服务器的原理、配置过程与应用。
二、实验环境
硬件:PC电脑一台,网络正常。
配置:win10系统,内存大于8G ,硬盘500G及以上。
软件:VMware、Ubuntu16.04。
三、实验内容
配置一台DNS服务器,域名为text.com,IP为192.168.1.100,主机名为
实验步骤
1、 本实验将在网络条件下进行
2、进入新建的用户,备份apt-get的源文件
程序运行截图:


3、更新apt-get源文件为阿里云源。(编辑/etc/source.list,)

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| deb https://mirrors.aliyun.com/ubuntu/ xenial main deb-src https://mirrors.aliyun.com/ubuntu/ xenial main deb https://mirrors.aliyun.com/ubuntu/ xenial-updates main deb-src https://mirrors.aliyun.com/ubuntu/ xenial-updates main deb https://mirrors.aliyun.com/ubuntu/ xenial universe deb-src https://mirrors.aliyun.com/ubuntu/ xenial universe deb https://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb-src https://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb https://mirrors.aliyun.com/ubuntu/ xenial-security main deb-src https://mirrors.aliyun.com/ubuntu/ xenial-security main deb https://mirrors.aliyun.com/ubuntu/ xenial-security universe deb-src https://mirrors.aliyun.com/ubuntu/ xenial-security universe deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse |
程序运行截图:

4、更新apt-get。

程序运行截图:

5、在线安装BIND9。

程序运行截图:

6、配置dns服务器,进入/etc/bind中

程序运行截图:

7、修改配置文件/etc/bind/named.conf.local


程序运行截图:

8、复制db.local,并重命名为db.text.name

程序运行截图:

9、修改db.text.name
程序运行截图:
服务器IP为192.168.19.128:

10、重启服务

程序运行截图:

12、分别测试abc.text.name www.text.name ns.text.name
程序运行截图:



13、安装apache2

程序运行截图:

14、在默认配置下,在Linux下的浏览器输入http://localhost,查看页面。
程序运行截图:

建立个人网站站点
15、在自己创建的用户主目录里面创建目录public_html,在该目录里新建index.html,并输入以下内容。


程序运行截图:



16、修改/etc/apache2/mods-available/userdir.conf的配置内容,把UserDir public_html前的#删掉,给UserDir disabled root加上#。
程序运行截图:


创建软连接。

程序运行截图:
bash
sudo ln -s /etc/apache2/mods-available/userdir.load /etc/apache2/mods-enabled/userdir.load
sudo ln -s /etc/apache2/mods-available/userdir.conf /etc/apache2/mods-enabled/userdir.conf

关闭防火墙和SELinux服务。

如果提示setenforce未安装,则执行以下命令:

程序运行截图:


重新启动apache服务。

sudo systemctl restart apache2
bash
sudo systemctl restart apache2
程序运行截图:

查看apache服务器的状态。
bash
systemctl status apache2

程序运行截图:
在Linux的浏览器下输入http://localhost/\~zx,zx为自己新建的用户。
程序运行截图:

查看Linux下apache服务器的IP地址。

程序运行截图:

常见问题提示 :
- 代码输入错误;
- 运行结果出现问题。
五、实验作业
1、根据要求,完成实验指导里的操作流程。
2、实验结果分析和实验总结:
setenforce是Linux系统中用于设置SELinux(Security-Enhanced Linux,安全增强型Linux)工作模式的命令。SELinux是一种安全机制,通过强制访问控制(Mandatory Access Control,MAC)来限制进程的权限,以保护系统免受恶意程序和攻击的威胁。执行setenforce 0
表示将SELinux设置为Permissive模式,此时SELinux不会阻止任何操作,但会记录安全策略违反的情况。
六、问题
如果按照以上流程不能正确运行代码,请找出原因。
实验过程中遇到问题不能下载bind9:
根据报错信息"bind9-libs (= 1:9.16.1-0ubuntu2) but 1:9.18.28-0ubuntu0.20.04.1 is to be installed",发现是之前下载的bind9-libs版本过高,于是先删除libs,再下载提示的版本bind9-libs=1:9.16.1-0ubuntu2,具体命令如下:$sudo apt remove bind9-libs $sudo apt install bind9-libs=1:9.16.1-0ubuntu2