序号 | 题目 | 需求 | 操做 |
1 | 配置SELinux system1&system2 |
要求SELinux的工做模式为enforcing,且重启依然有效 | vim /etc/selinux/config SELINUX=enforcing setenforce 1 getenforce |
2 | 配置SSH访问 system1&system2 |
容许 group8.example.com 域的客户对 system1 和 system2 进行 ssh 访问 禁止 my133t.org 域的客户对 system1 和 system2 进行 ssh 访问 备注: my133t.org 是在 172.13.8.0/24 网络 |
firewall-config firewall-cmd --list-all |
3 | 自定义用户环境 system1&system2 |
在系统system1和system2上建立自定义命令为qstat ,要求: 此自定义命令将执行如下命令:/bin/ps -Ao pid,tt,user,fname,rsz 此命令对系统中的全部用户有效 |
vim /etc/profile alias qstat='/bin/ps -Ao pid,tt,user,fname,rsz' source /etc/profile qstat |
4 | 配置端口转发 system1 |
在172.24.8.0/24网络中的系统,访问system1的本地端口 5423 将被转发到 80 此设置必须永久有效 |
firewall-config firewall-cmd --list-all 题目已经明确源IP,建议使用firewall富规则配置 |
5 | 配置链路聚合 system1&system2 |
此链路使用接口eth1和eth2 此链路在一个接口失效时仍然能工做 此链路在system1使用下面的地址172.16.3.40/255.255.255.0 此链路在system2使用下面的地址172.16.3.45/255.255.255.0 此链路在系统重启以后依然保持正常状态 |
nm-connection-editor JSON配置:{"runner":{"name":"activebackup"}} |
6 | 配置IPv6地址 system1&system2 |
system1上的地址应该是2003:ac18::305/64 system2上的地址应该是2003:ac18::30a/64 两个系统必须能与网络2003:ac18/64内的系统通讯 地址必须在重启后依然生效 两个系统必须保持当前的IPV4地址并能通讯 |
nm-connection-editor ping6 2003:ac18::305 ping6 2003:ac18::30a |
7.1 | 配置本地邮件服务 system1&system2 |
这些系统不接收外部发送来的邮件 | vim /etc/postfix/main.cf local_transport = error:local →新增100行 inet_interfaces = loopback-only →修改116行 |
7.2 | 从这些系统上发送的邮件显示来自于server.group8.example.com | myorigin = server.group8.example.com →修改99行 | |
7.3 | 在这些系统上本地发送的任何邮件都会自动路由到mail.group8.example.com | relayhost = [mail.group8.example.com] →修改313行 | |
7.4 | 重启postfix相关服务,并将服务加入到开机启动项 | systemctl restart postfix systemctl enable postfix |
|
7.5 | 测试验证 | mail dave | |
8.1 | 配置SMB共享目录 system1 |
安装samba服务 | yum install -y samba samba-client |
8.2 | 建立SMB共享目录 | mkdir /common | |
8.3 | 修改SMB目录SELinux上下文安全域 | chcon -R -t samba_share_t /common/ | |
8.4 | 您的SMB服务器必须是STAFF工做组的一个成员 | vim /etc/samba/smb.conf workgroup = STAFF |
|
8.5 | 共享/common目录,共享名必须为common 只有group8.example.com 域内的客户端能够访问common共享 共享目录/common必须是能够浏览的 |
[common] path = /common hosts allow = 172.24.8. browseable = yes |
|
8.6 | 用户andy必须可以读取共享中的内容,若是须要的话,验证密码是redhat | smbpasswd -a andy | |
8.7 | 配置防火墙策略 | firewall-cmd --permanent --add-service=samba firewall-cmd --reload |
|
8.8 | 重启SMB相关服务,并将服务加入到开机启动项 | systemctl restart smb nmb systemctl enable smb nmb |
|
9.1 | 配置多用户SMB挂载 system1 |
在system1经过SMB共享目录/devops ,并知足下列要求: | mkdir /devops |
9.2 | 修改SMB目录SELinux上下文安全域 | chcon -R -t samba_share_t /devops/ | |
9.3 | 配置用户akira目录/devops读写权限 | setfacl -m u:akira:rwx /devops/ | |
9.4 | 共享名为devops 共享目录devops只能group8.example.com域中的客户端使用 共享目录devops必须能够被浏览 用户silene必须能以读的方式访问此共享,访问密码是redhat 用户akira必须能以读写的方式访问此共享,访问密码是redhat |
vim /etc/samba/smb.conf [devops] path = /devops hosts allow = 172.24.8. browseable = yes writable = no write list = akira |
|
9.5 | 建立SMB用户 | smbpasswd -a silene smbpasswd -a akira |
|
9.6 | 重启SMB相关服务,并将服务加入到开机启动项 | systemctl restart smb nmb systemctl enable smb nmb |
|
9.8 | 配置多用户SMB挂载 system2 |
安装SMB相关客户端服务 | yum install -y samba-client cifs-utils |
9.9 | 查看system1的SMB共享 | smbclient -L //172.24.8.11/ -U silene | |
9.10 | 此共享永久挂载在system2.group8.example.com上的/mnt/dev 目录 | mkdir /mnt/dev | |
9.11 | 并使用用户silene做为认证任何用户,能够经过用户akira来临时获取写的权限 | vim /etc/fstab //172.24.8.11/devops /mnt/dev cifs defaults,multiuser,username=silene,password=redhat,sec=ntlmssp 0 0 |
|
9.12 | 挂载/etc/fstab中全部文件系统 | mount -a df -h |
|
9.13 | 测试验证,用户akira可读写 | su - akira cd /mnt/dev cifscred add 172.24.8.11 touch 123 |
|
9.14 | 测试验证,用户silene只读 | su - silene cd /mnt/dev cifscred add 172.24.8.11 cat 123 touch 456 |
|
10.1 | 配置NFS服务 system1 |
安装NFS服务 | yum install -y nfs-utils |
10.2 | 以只读的方式共享目录/public | mkdir /public | |
10.3 | 以读写的方式共享目录/protected,目录/protected应该包含名为project | mkdir -p /protected/project | |
10.4 | 子目录project全部者为andres andres能以读写方式访问/protected/project |
chown andres /protected/project ls -ld /protected/project |
|
10.5 | 修改SELinux上下文安全域 | chcon -R -t public_content_t /public/ chcon -R -t public_content_t /protected/ |
|
10.6 | 访问/protected须要经过Kerberos安全加密,您可使用下面URL提供的密钥 http://server.group8.example.com/pub/keytabs/system1.keytab |
wget -O /etc/krb5.keytab http://server.group8.example.com/pub/keytabs/system1.keytab vim /etc/sysconfig/nfs RPCNFSDARGS="-V 4.2" |
|
10.7 | NFS只读目录/public,只能被group8.example.com域中的系统访问 NFS读写目录/protected,只能被group8.example.com域中的系统访问 |
vim /etc/exports /public 172.24.8.0/24(ro) /protected 172.24.8.0/24(rw,sec=krb5p) |
|
10.8 | 配置防火墙策略 | firewall-cmd --permanent --add-service=nfs firewall-cmd --permanent --add-service=rpc-bind firewall-cmd --permanent --add-service=mountd firewall-cmd --reload |
|
10.9 | 重启NFS相关服务,并将服务加入到开机启动项 刷新并从新加载NFS配置 |
systemctl restart nfs-server rpcbind nfs-secure-server systemctl enable nfs=server rpcbind exportfs -ra 版本若为7.0,则执行如下操做: systemctl restart nfs-server rpcbind nfs-secure-server systemctl enable nfs=server rpcbind nfs-secure-server exportfs -ra |
|
11.1 | 挂载一个NFS共享 system2 |
检查system1 NFS共享状态 | showmount -e 172.24.8.11 |
11.2 | /public挂载到目录/mnt/nfsmount | mkdir /mnt/nfsmount | |
11.3 | /protected挂载到目录/mnt/nfssecure | mkdir /mnt/nfssecure | |
11.4 | 挂载/protected须要使用安全的方式,密钥下载URL以下: http://server.group8.example.com/pub/keytabs/system2.keytab |
wget -O /etc/krb5.keytab http://server.group8.example.com/pub/keytabs/system2.keytab | |
11.5 | 这些文件系统在系统启动时自动挂载 | vim /etc/fstab 172.24.8.11:/public /mnt/nfsmount nfs defaults 0 0 172.24.8.11:/protected /mnt/nfssecure nfs4 defautls,sec=krb5p 0 0 版本若为7.0,则执行如下操做: vim /etc/fstab 172.24.8.11:/public /mnt/nfsmount nfs defaults 0 0 172.24.8.11:/protected /mnt/nfssecure nfs defautls,sec=krb5p,v4.2 0 0 |
|
11.6 | 重启NFS相关服务,并将服务加入到开机启动项 | systemctl restart nfs-secure nfs-client.target systemctl enable nfs-client.target 版本若为7.0,则执行如下操做: systemctl restart nfs-secure systemctl enable nfs-secure |
|
11.7 | 挂载/etc/fstab中全部文件系统 | mount -a df -h |
|
11.8 | 测试验证 | su - andres kinit cd /mnt/nfssecure/project/ touch 123 |
|
12.1 | 实现一个Web服务器 system1 |
安装HTTPD服务 | yum install -y httpd |
12.2 | 拷贝HTTPD配置文件模板到配置文件目录 | cp /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/ | |
12.3 | 编辑HTTPD配置文件 | vim /etc/httpd/conf.d/httpd-vhosts.conf <VirtualHost *:80> DocumentRoot "/var/www/html" ServerName system1.group8.example.com </VirtualHost> |
|
12.4 | 从http://server.group8.example.com/pub/system1.html 下载文件,而且将文件重名为index.html不要修改此文件的内容 | wget -O /var/www/html/index.html http://server.group8.example.com/pub/system1.html | |
12.5 | 配置防火墙策略 | firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https firewall-cmd --reload |
|
12.6 | 重启httpd相关服务,并将服务加入到开机启动项 | systemctl restart httpd systemctl enble httpd |
|
12.7 | 来自于my133t.org域的客户端拒绝访问此web服务 | firewall-config firewall-cmd --list-all |
|
13.1 | 配置安全Web服务 system1 |
安装HTTPS模块 | yum install -y mod_ssl |
13.2 | 下载公钥、私钥和证书到/var/www/html目录 | cd /var/www/html wget http://***.crt wget http://***.key wget http://***ca.crt |
|
13.3 | 提取SSL配置模板参数 | grep SSL /etc/httpd/conf.d/ssl.conf > /etc/httpd/conf.d/ssl vim /etc/httpd/conf.d/ssl SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA SSLHonorCipherOrder on SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.key SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt |
|
13.4 | 编辑HTTPD配置文件 | vim /etc/httpd/conf.d/httpd-vhosts.conf <VirtualHost *:443> DocumentRoot "/var/www/html" ServerName system1.group8.example.com SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 SSLHonorCipherOrder on SSLCertificateFile /var/www/html/system1.crt SSLCertificateKeyFile /var/www/html/system1.key SSLCACertificateFile /var/www/html/ssl-ca.crt </VirtualHost> |
|
13.5 | 重启httpd相关服务,并将服务加入到开机启动项 | systemctl restart httpd systemctl enble httpd |
|
13.6 | 来自于my133t.org域的客户端拒绝访问此web服务 | firewall-config firewall-cmd --list-all |
|
14.1 | 配置虚拟主机 system1 |
设置DocumentRoot 为 /var/www/virtual | mkdir /var/www/virtual |
14.2 | 从http://server.group8.example.com/pub/www8.html下载文件重名为 index.html ,不要对文件 index.html 的内容作任何修改 | wget -O /var/www/virtual/index.html http://server.group8.example.com/pub/www8.html | |
14.3 | 确保andy用户可以在/var/www/virtual 目录下建立文件 | setfacl -m u:andy:rwx /var/www/virtual/ | |
14.4 | 并将文件index.html放到虚拟主机的DocumentRoot目录下,并编辑HTTPD配置文件 | vim /etc/httpd/conf.d/httpd-vhosts.conf <VirtualHost *:80> DocumentRoot "/var/www/virtual" ServerName www8.group8.example.com </VirtualHost> |
|
14.5 | 重启httpd相关服务,并将服务加入到开机启动项 | systemctl restart httpd systemctl enble httpd |
|
15.1 | 配置Web内容访问 system1 |
在您的system1上的web服务器的DocumentRoot目录下,建立一个名为private的目录 | mkdir html/private mkdir virtual/private |
15.2 | 从http://server.group8.example.com/pub/private.html下载一个文件副本到这个目录,而且重命名为 index.html | wget -O /var/www/html/private/index.html http://server.group8.example.com/pub/private.html wget -O /var/www/virtual/private/index.html http://server.group8.example.com/pub/private.html |
|
15.3 | 参考httpd主配置文件,摘取内容访问控制配置模板 | cat /etc/httpd/conf/httpd.conf <Directory /> AllowOverride none Require all denied </Directory> |
|
15.4 | 从 system1 上,任何人均可以浏览 private 的内容,可是从其它系统不能访问这个目录的内容。 | /etc/httpd/conf.d/httpd-vhosts.conf <Directory "/var/www/html/private"> AllowOverride none Require all denied Require local </Directory> <Directory "/var/www/virtual/private"> AllowOverride none Require all denied Require local </Directory> |
|
15.5 | 重启httpd相关服务,并将服务加入到开机启动项 | systemctl restart httpd systemctl enble httpd |
|
16.1 | 实现动态Web内容 system1 |
安装HTTPD动态脚本模块mod_wsgi | yum install -y mod_wsgi |
16.2 | 建立动态脚本目录,并下载动态脚本 | mkdir /var/www/wsgi/ cd /var/www/wsgi/ wget http://server.group8.example.com/pub/webinfo.wsgi |
|
16.3 | 虚拟主机侦听在端口8909,编辑httpd配置文件 | vim /etc/httpd/conf.d/httpd-vhosts.conf Listen 8909 <VirtualHost *:8909> ServerName wsgi.group8.example.com WSGIScriptAlias / /var/www/wsgi/webinfo.wsgi </VirtualHost> |
|
16.4 | 配置SELinux安全端口 | semanage port -l | grep http semanage port -a -t http_port_t -p tcp 8909 |
|
16.5 | 配置防火墙策略,开放TCP 8909端口 | firewall-cmd --permanent --add-port=8909/tcp firewall-cmd --reload |
|
16.6 | 重启httpd相关服务,并将服务加入到开机启动项 | systemctl restart httpd systemctl enble httpd |
|
17 | 建立一个脚本 system1 |
建立脚本 注意最后脚本文件须要赋予755权限 |
#! /bin/bash case $1 in redhat) echo fedora ;; fedora) echo redhat ;; *) echo '/root/foo.sh redhat | fedora' ;; esac |
18.1 | 建立添加用户的脚本 system1 |
下载用户清单文件 | cd /root wget http://server.group8.example.com/pub/userlist |
18.2 | 建立脚本 注意最后脚本文件须要赋予755权限 |
#! /bin/bash if [ $# -eq 0 ]; then echo 'Usage: /root/batchusers userfile' exit 1 fi if [ ! -f $1 ]; then echo 'Input file not found' exit 1 fi while read line do useradd -s /bin/false $line done < $1 |
|
19.1 | 配置iscsi服务端 system1 |
建立LVM逻辑卷iscsi_store 使用 iscsi_store 做其后端逻辑卷名称,其大小为 3G |
fdisk /dev/sda,划分出3G逻辑分区 pvcreat /dev/sda6 vgcreat iscsi_vg /dev/sda6 lvcreat -l 100%VG -n iscsi_store iscsi_vg |
19.2 | 安装iscsi | yum install -y targetd targetcli | |
19.3 | 配置iscsi服务端 | targetcli cd /backstores/block creat disk0 /dev/iscsi_vg/iscsi_store cd /iscsi creat iqn.2014-08.com.example.group8:system1 cd iqn.2014-08.com.example.group8:system1/tpg1/luns create /backstores/block/disk0 cd iqn.2014-08.com.example.group8:system1/tpg1/acls create iqn.2014-08.com.example.group8:system2 cd iqn.2014-08.com.example.group8:system1/tpg1/portals delete 0.0.0.0 3260 create 172.24.8.11 exit |
|
19.4 | 重启iscsi服务,并加入到开机启动项 | systemctl restart target systemctl enable target |
|
19.5 | 此服务只能被 system2.group8.example.com 访问 | firewall-config 开通仅容许system2访问3260端口 | |
20.1 | 配置iscsi客户端 system2 |
安装iscsi客户端服务程序,RHEL7默认已经安装 | yum install -y iscsi-initiator-utils |
20.2 | 扫描发现system1的iscsi服务 | iscsiadm -m discovery -t st -p 172.24.8.11 | |
20.3 | 编辑iscsi客户端服务配置文件 | vim /etc/iscsi/initiatorname.iscsi | |
20.4 | 重启iscsi客户端服务,并加入到开机启动项 | systemctl restart iscsi iscsid systemctl enable iscsi iscsid |
|
20.5 | 登陆system1的iscsi服务 | iscsiadm -m node -T iqn.2014-08.com.example.group8:system2 -p 172.24.8.11 --login | |
20.6 | 块设备 iSCISI 上包含一个大小为 2100 MiB 的分区,并格式化为 ext4 | fdisk /dev/sdb mkfs.ext4 /dev/sdb1 |
|
20.7 | 此分区挂载在 /mnt/data 上,建立目录 | mkdir /mnt/data | |
20.8 | 同时在系统启动的期间自动挂载,编辑fstab文件 注意:必定要用UUID挂载,lsblk,blkid |
vim /etc/fstab UUID=****** /mnt/data ext4 defaults,_netdev 0 0 |
|
20.9 | 挂载iscsi | mount -a df -h |
|
21.1 | 配置一个数据库 system1 |
安装mariaDB | yum install -y mariadb* |
21.2 | 数据库只能被 localhost 访问,修改数据库配置文件 | vim /etc/my.conf skip-networking=1 |
|
21.3 | 重启数据库服务,并加入到开机启动项 | systemctl restart mariadb systemctl enable mariadb |
|
21.4 | 下载须要恢复的数据库文件 | cd /root wget http://server.group8.example.com/pub/users.mdb |
|
21.5 | 进入数据库,建立数据库,并恢复数据库表文件 在 system1上建立一个 Maria DB 数据库,名为 Contacts |
mysql -u root -p create database Contacts; show databases; use Contacts; source /root/users.mdb; |
|
21.6 | 除了 root 用户,此数据库只能被用户 Mary 查询,此用户密码为 redhat | grant select on Contacts.* to Mary@localhost identified by 'redhat'; | |
21.7 | 初始化数据库,root 用户的数据库密码为 redhat ,同时不容许空密码登陆 | mysql_secure_installation |