2020年度CE考题解析

2020年度CE考题解析

1.配置防火墙端口转发

在系统 server0 上配置端口转发,要求如下:
在 172.25.0.0/24 网络中的系统,访问 server0 的本地端口 5423 将被转发到80
此设置必须永久有效

#firewall-cmd --set-default-zone=trusted
#firewall-cmd --permanent --zone=trusted --add-forward-port=port=5423:proto=tcp:toport=80
#firewall-cmd --reload

2.配置链路聚合

在 server0.example.com 和 desktop0.example.com 之间按以下要求配置一个链路team0:
此链路使用接口 eth1 和 eth2
此链路在一个接口失效时仍然能工作
此链路在 server0 使用下面的地址 172.16.3.20/255.255.255.0
此链路在 desktop0 使用下面的地址 172.16.3.25/255.255.255.0
此链路在系统重启之后依然保持正常状态

server0:
#nmcli connection show
#man teamd.conf
#nmcli connection add type team con-name team0 ifname team0 autoconnect yes config ‘{“runner”: {“name”: “activebackup”}}’
#nmcli connection add type team-slave con-name team0-1 ifname eth1 autoconnect yes master team0
#nmcli connection add type team-slave con-name team0-2 ifname eth2 autoconnect yes master team0
#nmcli connection modify team0 ipv4.method manual ipv4.addresses ‘172.16.3.20/24’ connection.autoconnect yes
#nmcli connection up team0
#teamdctl team0 state

desktop0:
#nmcli connection add type team con-name team0 ifname team0 autoconnect yes config ‘{“runner”: {“name”: “activebackup”}}’
#nmcli connection add type team-slave con-name team0-1 ifname eth1 autoconnect yes master team0
#nmcli connection add type team-slave con-name team0-2 ifname eth2 autoconnect yes master team0
#nmcli connection modify team0 ipv4.method manual ipv4.addresses ‘172.16.3.25/24’ connection.autoconnect yes
#nmcli connection up team0
#teamdctl team0 state

3.自定义用户环境

在系统 server0 和 desktop0 上创建自定义命令为 :
此自定义命令将执行以下命令:/bin/ps -Ao pid,tt,user,fname,rsz
此命令对系统中所有用户有效

#/etc/bashrc
alias qstat=’/bin/ps -Ao pid,tt,user,fname,rsz

4.配置SELinux

确保您的两个虚拟机的SELinux处于强制启用模式
#/etc/selinux/config
SELINUX=enforcing
#setenforce 1

5.配置SSH访问

按以下要求配置 SSH 访问:
用户能够从域 example.com 内的客户端 SSH 远程访问您的两个虚拟机系统
在域 my133t.org 内的客户端不能访问您的两个虚拟机系统

方法一:
#/etc/ssh/sshd_config
DenyUsers @.my133t.org
DenyUsers @172.34.0.
#systemctl restart sshd

方法二:
server0
firewall-cmd --permanent --zone=trusted --add-source=172.25.0.0/24
#firewall-cmd --permanent --zone=block --add-source=172.34.0.0/24 desktop
#firewall-cmd --permanent --zone=trusted --add-source=172.25.0.0/24
#firewall-cmd --permanent --zone=block --add-source=172.34.0.0/24

6.配置IPv6地址

在您的两个考试系统上配置接口 eth0 使用下列 IPv6 地址:
server0 上的地址应该是 2003:ac18::305/64
desktop0 上的地址应该是 2003:ac18::306/64
两个系统必须能与网络 2003:ac18/64 内的系统通信
地址必须在重启系统后依旧生效
两个系统必须保持当前的 IPv4 地址并仍然能够通信

server0:
#nmcli connection modify “System eth0” ipv6.method manual ipv6.addresses ‘2003:ac18::305/64’ connection.autoconnect yes
#nmcli connection up ‘System eth0’
desktop0:~

7.配置本地邮件服务

在系统 server0 和 desktop0 上配置邮件服务,满足以下要求:
这些系统不接收外部发送来的邮件
在这些系统上本地发送的任何邮件都会自动路由到 smtp0.example.com
从这些系统上发送的邮件显示来自于 desktop0.example.com
您可以通过在 server0.example.com 发送邮件到本地用户 student 来测试您的配置,并将系统 desktop0.example.com 配置为后端邮件服务器,确保可接收并投递来自 server0 的邮件

server0:
#hostnamectl set-hostname server0.example.com
#vim /etc/postfix/main.cf
relayhost = [smtp0.example.com] 314
inet_interfaces = loopback-only 116
myorigin = desktop0.example.com 98
mynetworks = 127.0.0.0/8, [::1]/128 264
mydestination= 164
#systemctl restart postfix
#systemctl enable postfix
#echo ‘I am king.’ | mail -s ‘Test1’
desktop0:
#hostnamectl set-hostname desktop0.example.com
#mail -u root

8.通过 Samba 发布共享目录

在 server0 通过 SMB 共享/common 目录:
您的 SMB 服务器必须是 STAFF 工作组的一个成员
共享名必须为 common
只有 example.com 域内的客户端可以访问 common 共享
common 必须是可以浏览的
用户 harry 必须能够读取共享中的内容,如果需要的话,验证的密码是 migwhisk

#yum -y install samba
#mkdir /common
#setsebool -P samba_export_all_rw=on
#useradd harry
#pdbedit -a harry
#vim /etc/samba/smb.conf
[global]
workgroup = STAFF
[common]
path = /common
hosts allow = 172.25.0.0/24
[root@server0 ~]# systemctl restart smb nmb
[root@server0 ~]# systemctl enable smb nmb

9.配置多用户Samba挂载

在 server0 通过 SMB 共享目录/devops,并满足以下要求:
共享名为 devops
共享目录 devops 只能被 example.com 域中的客户端使用
共享目录 devops 必须可以被浏览
用户 kenji 必须能以读的方式访问此共享,该问密码是 atenorth
用户 chihiro 必须能以读写的方式访问此共享,访问密码是 atenorth
此共享永久挂载在 desktop0.example.com 上的/mnt/dev 目录,并使用用户 kenji 作为认证。任何用户可以通过用户 chihiro 来临时获取写的权限

server0:
#mkdir /devops
#useradd kenji
#pdbedit -a kenji
atenorth
#useradd chihiro
#pdbedit -a chihiro
atenorth
#setfacl -m u:chihiro:rwx /devops/
#vim /etc/samba/smb.conf
[global]
workgroup = STAFF
[devops]
path = /devops
write list = chihiro
hosts allow = 172.25.0.0/24
#systemctl restart smb nmb
#systemctl enable smb nmb

desktop0:
#yum -y install samba-client cifs-utils
#smbclient -L server0
//检查对方提供了哪些共享
… …
#mkdir /mnt/dev (创建好挂载点)
#vim /etc/fstab
//server0.example.com/devops /mnt/dev cifs username=kenji,password=atenorth,multiuser,sec=ntlmssp,_netdev 0 0
#mount -a
//检查挂载配置
#su - student
#touch /mnt/dev/b.txt

10.配置NFS共享服务

在 server0 配置 NFS 服务,要求如下:
以只读的方式共享目录 /public,只能被 example.com 域中的系统访问
以读写的方式共享目录 /protected,只能被 example.com 域中的系统访问
访问 /protected 需要通过 Kerberos 安全加密,您可以使用下面 URL 提供的密钥:http://classroom.example.com/pub/keytabs/server0.keytab
目录 /protected 应该包含名为 project 拥有人为 ldapuser0 的子目录
用户 ldapuser0 能以读写方式访问 /protected/project

#mkdir -p /public /protected/project
#chown ldapuser0 /protected/project
#wget -O /etc/krb5.keytab http://classroom.example.com/pub/keytabs/server0.keytab
#vim /etc/exports
/public 172.25.0.0/24(ro)
/protected 172.25.0.0/24(rw,sec=krb5p)
#systemctl restart nfs-secure-server nfs-server
#systemctl enable nfs-secure-server nfs-server

11.挂载NFS共享

在 desktop0 上挂载一个来自 server0.example.com 的共享,并符合下列要求:
/public 挂载在下面的目录上 /mnt/nfsmount
/protected 挂载在下面的目录上 /mnt/nfssecure 并使用安全的方式,密钥下载 URL:http://classroom.example.com/pub/keytabs/desktop0.keytab
用户 ldapuser0 能够在/mnt/nfssecure/project 上创建文件
这些文件系统在系统启动时自动挂载

#mkdir -p /mnt/nfsmount /mnt/nfssecure
#wget -O /etc/krb5.keytab http://classroom.example.com/pub/keytabs/desktop0.keytab
#systemctl start nfs-secure
#systemctl enable nfs-secure
#showmount -e server0
#vim /etc/fstab
server0.example.com:/public /mnt/nfssecure nfs _netdev 0 0
server0.example.com:/protected /mnt/nfssecure nfs sec=krb5p,_netdev 0 0
#mount -a
#ssh ldapuser0@desktop0
#cd /mnt/nfssecure/project
#touch test.txt

12.实现一个Web服务器

为 http://server0.example.com 配置 Web 服务器:
从URL地址 http://classroom.example.com/pub/materials/station.html 下载一个主页文件,并将该文件重命名为 index.html
将文件 index.html 拷贝到您的 web 服务器的 DocumentRoot 目录下
不要对文件 index.html 的内容进行任何修改

#yum -y install httpd
#vim /etc/httpd/conf.d/test1.conf
<VirtualHost *:80>
ServerName server0.example.com
DocumentRoot /var/www/html

#cd /var/www/html/
#wget http://classroom/pub/materials/station.html -O index.html -O 指定路径及重命名
#systemctl restart httpd
#systemctl enable httpd

13.配置虚拟主机

在 server0 上扩展您的 web 服务器,为站点 http://www0.example.com 创建一个虚拟主机,然后执行下述步骤:
设置 DocumentRoot 为/var/www/virtual
从 http://classroom.example.com/pub/materials/www.html 下载文件并重命名为index.html
不要对文件 index.html 的内容进行任何修改
将文件 index.html 放到虚拟主机的 DocumentRoot 目录下
确保 fleyd 用户能够在/var/www/virtual 目录下创建文件
注意:原始站点 http://server0.example.com 必须仍然能够访问,名称服务器 example.com 提供对主机名 www0.example.com 的域名解析。

#mkdir /var/www/virtual
#useradd fleyd
#chown -R fleyd /var/www/virtual
#cd /var/www/virtual
#wget http://classroom/pub/materials/www.html -O index.html
#vim /etc/httpd/conf.d/test2.conf
<VirtualHost *:80>
ServerName www0.example.com
DocumentRoot /var/www/virtual

#systemctl restart httpd

14.配置安全Web服务

为站点 http://server0.example.com 配置TLS加密:
一个已签名证书从 http://classroom.example.com/pub/tls/certs/server0.crt 获取
此证书的密钥从 http://classroom.example.com/pub/tls/private/server0.key 获取
此证书的签名授权信息从 http://classroom.example.com/pub/example-ca.crt 获取

#yum -y install mod_ssl
#cd /etc/pki/tls/certs
#wget http://classroom.example.com/pub/tls/certs/server0.crt
#wget http://classroom.example.com/pub/example-ca.crt
#cd /etc/pki/tls/private/
#wget http://classroom.example.com/pub/tls/private/server0.key
#vim /etc/httpd/conf.d/ssl.conf

DocumentRoot “/var/www/html”
ServerName server0.example.com:443 https 默认端口 443
SSLCertificateFile /etc/pki/tls/certs/server0.crt 100
SSLCertificateKeyFile /etc/pki/tls/private/server0.key 107
SSLCACertificateFile /etc/pki/tls/certs/example-ca.crt 122

15.配置Web内容访问

在您的 server0 web服务器的 DocumentRoot 目录下创建一个名为 的目录,要求如下:
从 http://classroom.example.com/pub/materials/private.html 下载一个文件副本到这个目录,并且命名为 index.html
不要对这个文件的内容做任何修改
从 server0 上,任何人都可以浏览 private 的内容,但是从其他系统不能访问这个目录的内容

#mkdir /var/www/html/private
#cd /var/www/html/private
#wget http://classroom.example.com/pub/materials/private.html -O index.html
#vim /etc/httpd/conf.d/test.conf

<Directory /var/www/html/private>
Require ip 172.0.0.1 ::1 172.25.0.11 允许访问地址

#systemctl restart httpd

16.实现动态Web内容

在 server0 上配置提供动态Web内容,要求如下:
动态内容由名为 webapp0.example.com 的虚拟主机提供
虚拟主机侦听在端口 8909
从 http://classroom.example.com/pub/materials/webinfo.wsgi 下载一个脚本,然后放在适当的位置,无论如何不要修改此文件的内容
客户端访问 http://webapp0.example.com:8909 可接收到动态生成的 Web 页
此 http://webapp0.example.com:8909/必须能被 example.com 域内的所有系统访问

#yum -y install mod_wsgi
#mkdir /var/www/webapp0
#cd /var/www/webapp0
#wget http://classroom.example.com/pub/materials/webinfo.wsgi
##vim /etc/httpd/conf.d/test1.conf

<VirtualHost *:80>
ServerName webapp0.example.com
DocumentRoot /var/www/webapp0
WSGIScriptAlias / /var/www/webapp0/webinfo.wsgi

Listen 8909
<VirtualHost *:8909>
ServerName webapp0.example.com
DocumentRoot /var/www/webapp0
WSGIScriptAlias / /var/www/webapp0/webinfo.wsgi

#semanage port -l |grep http 查看http selinux上下文值
#semanage port -a -t http_port_t -p tcp 8909 -a t添加 -t 类型 -p 协议
#systemctl restart httpd

17.创建一个脚本

在 server0 上创建一个名为/root/foo.sh 的脚本,让其提供下列特性:
当运行/root/foo.sh redhat,输出为 fedora
当运行/root/foo.sh fedora,输出为 redhat
当没有任何参数或者参数不是 redhat 或者 fedora 时,其错误输出产生以下的信息:/root/foo.sh redhat|fedora

#vim /root/foo.sh
#!/bin/bash
if [ $1 == ‘redhat’ ];then
echo ‘fedora’
elif [ $1 == ‘fedora’ ];then
echo ‘redhat’
else
echo ‘/root/foo.sh redhat|fedora’ >&2
exit 2
fi
#chmod +x /root/foo.sh

18.创建一个添加用户的脚本

在 server0 上创建一个脚本,名为/root/batchusers,此脚本能实现为系统 server0 创建本地用户,并且这些用户的用户名来自一个包含用户名的文件,同时满足下列要求:
此脚本要求提供一个参数,此参数就是包含用户名列表的文件
如果没有提供参数,此脚本应该给出下面的提示信息 Usage: /root/batchusers 然后退出并返回相应的值
如果提供一个不存在的文件名,此脚本应该给出下面的提示信息 Input file not found 然后退出并返回相应的值
创建的用户登陆Shell为/bin/false,此脚本不需要为用户设置密码
您可以从下面的 URL 获取用户名列表作为测试用:http://classroom.example.com/pub/materials/userlist
#vim /root/batchusers

#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: /root/batchusers "
exit 1
fi
if [ ! -f ‘$1’ ]; then
echo “Input file not found”
exit 2
fi
for i in $(cat $1)
do
useradd -s /bin/false $i
done
#chmod +x /root/batchusers

19.配置iSCSI服务端

配置 server0 提供一个 iSCSI 服务,磁盘名为 iqn.2016-02.com.example:server0,并符合下列要求:
服务端口为 3260
使用 iscsi_store 作其后端卷,其大小为 3GiB
此服务只能被 desktop0.example.com 访问

#fdisk /dev/vdb
+3G
#yum -y install targetcli
#targetcli

#systemctl restart target
#systemctl enable target

20.配置iSCSI客户端

配置 desktop0 使其能连接 server0 上提供的 iqn.2016-02.com.example:server0,并符合以下要求:
iSCSI设备在系统启动的期间自动加载
块设备iSCSI上包含一个大小为 2100MiB 的分区,并格式化为ext4文件系统
此分区挂载在 /mnt/data 上,同时在系统启动的期间自动挂载

#yum -y install iscsi-initiator-utils
#vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2016-02.com.example:desktop0
#systemctl restart iscsi
#systemctl enable iscsi
#man iscsiadm
#iscsiadm -m node -L all //手动连接磁盘测试
#lsblk
#fdisk /dev/sda
#partprobe /dev/sda
#mkfs.ext4 /dev/sda1
#blkid /dev/sda1
#mkdir /mnt/data
#vim /etc/fstab
UUID=“6ff20bb3-7543-4fa0-b4fa-bdc99a1e63ce” /mnt/data ext4 _netdev 0 0
#mount -a

21.配置一个数据库

在 server0 上创建一个 MariaDB 数据库,名为 Contacts,并符合以下条件:
数据库应该包含来自数据库复制的内容,复制文件的 URL 为:http://classroom.example.com/pub/materials/users.sql
数据库只能被 localhost 访问
除了root用户,此数据库只能被用户 Raikon 查询,此用户密码为 atenorth
root用户的密码为 atenorth,同时不允许空密码登陆

#wget http://classroom.example.com/pub/materials/users.sql
#mysqladmin -u root password “atenorth”
#mysql -u root -p’atenorth’ Contacts < /root/users.sql
#create database Contacts;
#grant select on Contacts.* to Raikon@localhost identified by ‘atenorth’;
#delete from mysql.user where password="";

22.数据库查询

在系统 server0 上使用数据库 Contacts,并使用相应的 SQL 查询以回答下列问题:
密码是 solicitous 的人的名字?
有多少人的姓名是 Barbara 同时居住在 Sunnyvale?

#select name from base where password=‘solicitous’;
#select count(*) from base,location where base.name=‘Barbara’
location.city=‘Sunnyvale’ and base.id=location.id;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值