前言
RHCE练习题目。
考试环境介绍
- 虚拟机设置:取消勾选cpu的计数器

- 虚拟机开启之后,里面还有3台虚拟机。
server0命名为System1,IP地址是172.25.0.11。密码:root/redhat

desktop0命名为System2,IP地址是172.25.0.10。密码:root/redhat

classroom默认开机的,保持开机状态即可。

- 可在虚拟机里面ssh到System1和System2

配置SELINUX
检查一下System1和System2的selinux配置文件/etc/selinux/config

配置SSH访问
1 2
| 用户能够从域 domain1.example.com 内的客户端通过SSH远程访问您的两个虚拟机系统 在域 my133t.org 内的客户端不能访问您的两个虚拟机系统
|
对System1和System2进行相同的操作:

1
| vim /etc/hosts.deny #这里是假设my133t.org解析出的IP是172.25.0.30
|

自定义用户环境
1
| 在系统 system1 和 system2上创建自定义命令名为 qstat 此自定义命令将执行以下命令: /bin/ps -Ao pid,tt,user,fname,rsz此命令对系统中所有用户有效。
|


配置端口转发
1
| 在系统system1配置端口转发,要求如下:在 172.24.1.0/24 网络中的系统,访问 system1 的本地端口 5423 将被转发到80 此设置必须永久有效
|
进入System1的虚拟机进行操作:



配置链路聚合
1 2 3 4 5 6
| 在 system1.domain1.example.com 和 system2.domain1.example.com 之间按以下要求配置一个链路: 此链路使用接口 eth1 和 eth2 此链路在一个接口失效时仍然能工作 此链路在 system1 使用下面的地址 172.16.1.25/255.255.255.0 此链路在 system2 使用下面的地址 172.16.1.35/255.255.255.0 此链路在系统重启之后依然保持正常状态
|










配置IPv6地址
1 2 3 4 5 6
| 在您的考试系统上配置接口 eth0 使用下列IPv6地址: system1 上的地址应该是 2001:ac18::10a/64 system2 上的地址应该是 2001:ac18::114/64 两个系统必须能与网络 2001:ac18/64 内的系统通信。 地址必须在重启后依旧生效。 两个系统必须保持当前的IPv4地址并能通信。
|



配置本地邮件服务
1 2 3 4 5
| 在系统system1 和 system2 上 配置邮件服务,满足以下要求: 这些系统不接收外部发送来的邮件 在这些系统上本地发送的任何邮件都会自动路由到 rhgls.domain1.example.com 从这些系统上发送的邮件显示来自于 domain1.example.com 您可以通过发送邮件到本地用户 'dave' 来测试您的配置, 系统 rhgls.domain1.example.com 已经配置把此用户的邮件转到下列URL http://rhgls.domain1.example.com/received_mail/1
|
- 编辑配置文件/etc/postfix/main.cf


- 重启postfix服务并加入开机启动项
1 2
| systemctl restart postfix systemctl enable postfix
|
- 配置防火墙,开放smtp服务


- 测试:发邮件给dave,可在 http://rhgls.domain1.example.com/received_mail/1看到邮件内容,说明服务配置成功
1
| mail -s "test" to dave@domain1.example.com
|
通过SMB共享服务
1 2 3 4 5 6
| 在system1上配置SMB服务 您的 SMB 服务器必须是 STAFF 工作组的一个成员 共享 /common 目录 共享名必须为 common 只有 domain1.example.com 域内的客户端可以访问 common 共享 common 必须是可以浏览的 用户 andy 必须能够读取共享中的内容,如果需要的话,验证的密码是 flectrag
|
- 在System1安装samba、samba-client
1
| yum install samba samba-client
|
- 创建目录/common
- 编辑samba配置文件/etc/samba/smb.conf,重启smb、nmb并加入开机启动项


1 2
| systemctl restart smb nmb systemctl enable smb nmb
|
- 添加用户andy

- 设置防火墙,放开samba和mountd服务


- 在System2测试samba共享是否成功
- 安装samba-client、cifs-utils
1
| yum install samba-client cifs-utils
|
- 测试samba共享目录

配置多用户samba挂载
1 2 3 4 5 6 7 8
| 在system1 共享通过SMB目录 /miscellaneous 满足以下要求: 共享名为 miscellaneous 共享目录 miscellaneous 只能被 domain1.example.com 域中的客户端使用 共享目录 miscellaneous 必须可以被浏览 用户 silene 必须能以读的方式访问此共享, 访问密码是 flectrag 用户 akira 必须能以读写的方式访问此共享, 访问密码是 flectrag 此共享永久挂载在 system2.domain1.example.com 上的 /mnt/multi 目录, 并使用用户 silene 作为认证 任何用户可以通过用户 akira 来临时获取写的权限
|
- 在system1进行以下操作:
1 2 3 4 5 6 7 8 9 10 11 12 13
| [root@system1 ~]# mkdir /miscellaneous/ [root@system1 ~]# chmod o+w /miscellaneous/ [root@system1 ~]# chcon -R -t samba_share_t /miscellaneous/ [root@system1 ~]# smbpasswd -a silene [root@system1 ~]# smbpasswd -a akira [root@system1 ~]# vim /etc/samba/smb.conf [miscellaneous] path=/miscellaneous hosts allow = 172.25.0. browseable = yes writable = no write list = akira [root@system1 ~]# systemctl restart smb nmb
|
- 在system2进行以下操作:
1 2 3 4 5 6
| [root@system2 ~]# smbclient -L //172.25.0.11 -U silene [root@system2 ~]# yum install cifs* [root@system2 ~]# mkdir /mnt/multi [root@system2 ~]# vim /etc/fstab //172.24.1.5/miscellaneous /mnt/multi cifs defaults,multiuser,username=silene,password=flectrag,sec=ntlmssp 0 0 [root@system2 ~]# mount -a
|
配置NFS共享
1 2 3 4 5 6 7 8 9 10 11
| 在 system1 配置NFS服务,要求如下: 以只读的方式共享目录 /public 同时只能被 domain1.example.com 域中的系统访问 以读写的方式共享目录 /protected 能被 domain1.example.com 域中的系统访问 访问 /protected 需要通过Kerberos安全加密, 您可以使用下面URL提供的密钥 http://host.domain1.example.com/materials/nfs_server.keytab 目录 /protected 应该包含名为 confidential 拥有人为deepak 的子目录 用户 deepak 能以读写方式访问 /protected/confidential 在 system2 上挂载一个来自 system1.domain1.example.com 的NFS共享, 并符合下列要求: /public 挂载在下面的目录上 /mnt/nfsmount /protected 挂载在下面的目录上 /mnt/nfssecure 并使用安全的方式,密钥下载URL如下: http://host.domain1.example.com/materials/nfs_client.keytab 用户 deepak 能够在 /mnt/nfssecure/confidential 上创建文件 这些文件系统在系统启动时自动挂载
|
- System1执行以下操作:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| [root@system1~]# mkdir/public [root@system1~]# mkdir -p /protected/confidential [root@system1~]# chcon -R -t public_content_t /public/ [root@system1~]# chcon -R -t public_content_t /protected [root@system1~]# chown deepak /protected/confidential [root@system1~]# vim /etc/exports /public 172.24.1.0/24(ro) /protected 172.24.1.0/24(rw,sec=krb5p) [root@system1~]# wget -O /etc/krb5.keytab http://host.domain1.example.com/materials/nfs_server.keytab [root@system1~]# vim /etc/sysconfig/nfs RPCNFSDARGS="-V4.2" [root@system1~]# systemctl start nfs-server nfs-secure-server [root@system1~]# systemctl enable nfs-server nfs-secure-server [root@system1~]# firewall-cmd --permanent --add-service=nfs [root@system1~]# firewall-cmd --permanent --add-service=rpc-bind [root@system1~]# firewall-cmd --reload [root@system1~]# exportfs -r
|
- System2执行以下操作:
1 2 3 4 5 6 7 8 9 10
| [root@system2 ~]# showmount -e system1 [root@system2 ~]# systemctl start nfs-secure [root@system2 ~]# systemctl enable nfs-secure [root@system2 ~]# wget -O /etc/krb5.keytab http://host.domain1.example.com/materials/nfs_client.keytab [root@system2 ~]# mkdir /mnt/nfsmount [root@system2 ~]# mkdir /mnt/nfssecure [root@system2 ~]# vim /etc/fstab 172.24.1.5:/public /mnt/nfsmount nfs defaults 0 0 172.24.1.5:/protected /mnt/nfssecure nfs defaults,sec=krb5p,v4.2 0 0 [root@system2 ~]# mount -a
|
完成web服务器
1 2 3 4 5
| 在 system1 上配置一个站点 http://system1.domain1.example.com 然后执行下述步骤: 从 http://rhgls.domain1.example.com/materials/station.html 下载文件,并且将文件重命名为 index.html 不要修改此文件的内容 将文件 index.html 拷贝到您的 web 服务器的 DocumentRoot 目录下 来自于 domain1.example.com 域的客户端可以访问此Web服务 来自于 my133t.org 域的客户端拒绝访问此Web服务
|
- 安装httpd
- 拷贝页面内容
把页面内容放到/var/www/html目录,命名为index.html
- 编辑配置文件/etc/httpd/conf.d/httpd-vhosts.conf

- 重启httpd服务并加入开机启动项
1 2
| systemctl restart httpd systemctl enable httpd
|
- 防火墙放开http、https服务


配置安全web服务
1
| 为站点 http://system1.domain1.example.com 配置TLS加密 一个已签名证书从 http://host.domain1.example.com/materials/system1.crt 获取 此证书的密钥从 http://host.domain1.example.com/materials/system1.key 获取 此证书的签名授权信息从 http://host.domain1.example.com/materials/domain1.crt 获取
|
- 安装mod_ssl模块
- 下载证书到/var/www/html目录

- 编辑配置文件/etc/httpd/conf.d/httpd-vhosts.conf,严格区分大小写

- 设置selinux安全上下文

- 重启httpd服务
- 验证https服务是否生效
在浏览器输入https://server0.example.com,看到有一个小锁就说明配置成功。

配置虚拟主机
1 2 3 4 5 6
| 在 system1 上扩展您的 web 服务器,为站点 http://www.domain1.example.com创建一个虚拟主机,然后执行下述步骤: 设置 DocumentRoot 为 /var/www/virtual 从 http://rhgls.domain1.example.com/materials/www.html 下载文件并重命名为 index.html 不要对文件 index.html 的内容做任何修改 将文件 index.html 放到虚拟主机的 DocumentRoot 目录下 确保 andy 用户能够在 /var/www/virtual 目录下创建文件
|




配置web内容访问
1 2 3 4
| 在您的system1 上的 web 服务器的 DocumentRoot 目录下 创建一个名为 secret 的目录,要求如下: 从 http://rhgls.domain1.example.com/materials/private.html 下载一个文件副本到这个目录,并且重命名为 index.html。 不要对这个文件的内容做任何修改。 从 system1 上,任何人都可以浏览 secret 的内容, 但是从其它系统不能访问这个目录的内容
|


从System2访问http://server0.example.com/secret/被拒绝,说明配置成功。

实现web动态内容
1 2 3 4 5 6
| 在 system1 上配置提供动态Web内容,要求如下: 动态内容由名为dynamic.domain1.example.com的虚拟主机提供 虚拟主机侦听在端口 8998 从 http://rhgls.domain1.example.com/materials/webapp.wsgi 下载一个脚本,然后放在适当的位置, 无论如何不要求修改此文件的内容 客户端访问 http://dynamic.domain1.example.com:8998/ 时 应该接收到动态生成的web页面 此 http://dynamic.domain1.example.com:8998/ 必须能被 domain1.example.com 域内的所有系统访问
|




创建一个脚本
1 2 3 4 5
| 在system1上创建一个名为 /root/script 的脚本, 让其提供下列特性: 当运行 /root/script foo,输出为 bar 当运行 /root/script bar,输出为 foo 当没有任何参数或者参数不是 foo 或者 bar时, 其错误输出产生以下的信息: /root/script foo|bar
|


创建一个添加用户的脚本
1 2 3 4 5 6 7
| 在 system1 上创建一个脚本,名为 /root/mkusers , 此脚本能实现为系统 system1 创建本地用户, 并且这些用户 的用户名来自一个包含用户名列表的文件。同时满足下列要求: 此脚本要求提供一个参数,此参数就是包含用户名列表的文件 如果没有提供参数,此脚本应该给出下面的提示信息 Usage: /root/mkusers userfile 然后退出并返回相应的值 如果提供一个不存在的文件名,此脚本应该给出下面的提示信息 Input file not found 然后退出并返回相应的值 创建的用户登录shell为 /bin/false 此脚本不需要为用户设置密码 您可以从下面的URL获取用户名列表作为测试用 http://rhgls.domain1.example.com/materials/userlist
|


配置iSCSI服务端
1 2 3 4
| 配置 system1 提供一个 iSCSI 服务 磁盘名为 iqn.2014-12.com.example.domain1:system1 ,并符合下列要求: 服务端口为 3260 使用 iscsi_vol 作其后端卷 其大小为 3G 此服务只能被 system2.domain1.example.com 访问
|
- 安装target相关软件包
- 重启target服务并加入开机启动项
1 2
| systemctl restart target systemctl enable target
|
- 设置iscsi

- 重启target服务
1
| systemctl restart target
|
- 设置防火墙规则

- 在system2进行验证


配置iSCSI客户端
1 2 3 4
| 配置 system2 使其能连接 在 system1 的上提供的 iqn.2014-12.com.example.domain1:system1 并符合以下要求: iSCSI 设备在系统启动的期间自动加载 块设备 iSCSI 上包含一个大小为 1700 MiB 的分区,并格式化为 xfs 此分区挂载在 /mnt/data 上 同时在系统启动的期间自动挂载
|



配置一个数据库
1 2 3 4 5
| 在 system1 上创建一个 MariaDB 数据库, 名为 Contacts ,并符合以下条件: 数据库应该包含来自数据库复制的内容,复制文件的URL为 http://rhgls.domain1.example.com/materials/users.mdb 。 数据库只能被 localhost 访问。 除了root用户, 此数据库只能被用户 Luigi 查询。 此用户密码为 flectrag 。 root 用户的密码为 flectrag , 同时不允许空密码登录。
|
- 安装mariadb、mariadb-client
1
| yum groupinstall mariadb mariadb-client
|
- 编辑配置文件/etc/my.cnf

- 重启mariadb并加入开机启动项
1 2
| systemctl restart mariadb systemctl enable mariadb
|
- 恢复数据库mariadb.dump并设置Luigi用户的权限



- 数据库初始化,设置root用户密码


数据库查询
1 2 3
| 数据库查询,在系统 system1上使用数据库 Contacts, 并使用相应的SQL查询以回答下列问题: 密码是 tangerine 的人的名字? 用户ID号码为4654的用户名成是?
|

重启机器,检查题目