1.
配置
SELinux
SELinux
必须在两个系统
system1
和
system2
中运行于
Enforcing
模式
[root@system1 /]#
setenforce 1
[root@system2 etc]#
setenforce 1
[root@system1 /]# cat /etc/selinux/config
SELINUX=enforcing
SELINUXTYPE=targeted
[root@system2 etc]# cat /etc/selinux/config
SELINUX=enforcing
SELINUXTYPE=targeted
2.
配置
SSH
访问
按以下要求配置
SSH
访问
:
用户能够从域
rhce.cc
内的客户端通过
SSH
远程访问您的两个虚拟机系统
[root@system1 /]#
cat /etc/hosts.allow
sshd : 192.169.122.0/255.255.255.0
[root@system1 /]#
cat /etc/hosts.deny
[root@system1 /]#scp /etc/hosts.allow /etc/hosts.deny 192.168.122.200:/etc/
3.
自定义用户环境
在系统
system1
和
system2
上创建自定义命令名为
qstat
此自定义命令将执行以下命令
:
/bin/ps -Ao pid,tt,user,fname,rsz
此命令对系统中所有用户有效。
[root@system1 /]#
cat /etc/bashrc
alias qstat=’ /bin/ps -Ao pid,tt,user,fname,rsz’
[root@system1 /]#scp /etc/bashrc 192.168.122.200:/etc/
4.
配置端口转发
在系统
system1
配置端口转发,
要求如下:
在
192.168.122.0/24
网络中的系统,
访问
system1
的本地端口
5423
将被转发到
80
此设置必须永久有效
[root@system1 /]#firewall-cmd --list-rich-rules
[root@system1 /]#firewall-cmd --add-rich-rule ‘rule family=ipv4 source address=192.168.122.0/24 forward-port port=5423 protocal=tcp to-port=80’ --permanent
5.
配置聚合链路
在
system1.rhce.cc
和
system2.rhce.cc
之间按以下要求配置一个链路:
此链路使用接口
eth1
和
eth2
此链路在一个接口失效时仍然能工作
此链路在
system1
使用下面的地址
172.16.11.25/255.255.255.0
此链路在
system2
使用下面的地址
172.16.11.35/255.255.255.0
此链路在系统重启之后依然保持正常状态
[root@system1 /]#nmcli connection add type team con-name team0 ifname team0 config ‘{“runner”:{“name”:”activebackup”}}’
[root@system1 /]#nmcli connection modify team0 ipv4.addresses “172.16.11.25/24”
[root@system1 /]#nmcli connection modify team0 ipv4.method manual
[root@system1 /]#nmcli connection add type team-slave con-name team0-1 ifname eth1 master team0
[root@system1 /]#nmcli connection add type team-slave con-name team0-2 ifname eth2 master team0
[root@system1 /]#systemctl restart network
[root@system2 etc]#nmcli connection add type team con-name team0 ifname team0 config ‘{“runner”:{“name”:”activebackup”}}’
[root@system2 etc]#nmcli connection modify team0 ipv4.addresses “172.16.11.35/24”
[root@system2 etc]#nmcli connection modify team0 ipv4.method manual
[root@system2 etc]#nmcli connection add type team-slave con-name team0-1 ifname eth1 master team0
[root@system2 etc]#nmcli connection add type team-slave con-name team0-2 ifname eth2 master team0
[root@system2 etc]#systemctl restart network
6.
配置
IPv6
地址
在您的考试系统上配置接口
eth0
使用下列
IPv6
地址:
system1
上的地址应该是
200e:ac18::e0a/64
system2
上的地址应该是
200e:ac18::e14/64
两个系统必须能与网络
200e:ac18/64
内的系统通信。
地址必须在重启后依旧生效。
两个系统必须保持当前的
IPv4
地址并能通信。
[root@system1 /]#nmcli connection modify eth0 ipv6.method auto
[root@system1 /]#nmcli connection modify eth0 ipv6.addresses "200e:ac18::e0a/64"
[root@system1 /]#nmcli connection modify eth0 ipv6.method manual
[root@system1 /]#systemctl restart network
[root@system2 etc]#nmcli connection modify eth0 ipv6.method auto
[root@system2 etc]# nmcli connection modify eth0 ipv6.addresses "200e:ac18::e14/64"
[root@system2 etc]#nmcli connection modify eth0 ipv6.method manual
[root@system2 etc]#systemctl restart network
7.
配置本地邮件服务
在系统
system1
和
system2
上
配置邮件服务,满足以下要求:
这些系统不接收外部发送来的邮件
在这些系统上本地发送的任何邮件都会自动路由到
rhgls.rhce.cc
从这些系统上发送的邮件显示来自于
rhce.cc
您可以通过发送邮件到本地用户
'dave'
来测试您的配置,系统
rhgls.rhce.cc
已经配置把此
[root@system1 /]#cat /etc/postfix/main.cf
mydestination =
relayhost = [rhgls.rhce.cc]
myorigin = rhce.cc
[root@system1 /]#systemctl restart postfix
[root@system1 /]#scp /etc/postfix/main.cf system2.rhce.cc:/etc/postfix/
[root@system2 etc]# systemctl restart postfix
[root@system2 etc]#echo abc123 | mail –s sss dave
8.
通过
SMB
共享目录
在
system1
上配置
SMB
服务
您的
SMB
服务器必须是
STAFF
工作组的一个成员
共享
/common
目录
共享名必须为
common
只有
rhce.cc
域内的客户端可以访问
common
共享
common
必须是可以浏览的
用户
andy
必须能够读取共享中的内容,如果需要的话,验证的密码是
redhat
[root@system1 /]#yum install samba -y
[root@system1 /]#cat /etc/samba/smb.cnf
添加以下内容:
workgroup = STAFF
[common]
path=/common
hosts allow =192.168.122.0/24
[root@system1 /]#mkdir /common
[root@system1 /]#chcon –R –t samba_share_t /common/
[root@system1 /]#useradd andy
[root@system1 /]#pdbedit –L
[root@system1 /]#yum whatprovides */smbpasswd
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
aa/filelists_db | 3.0 MB 00:00
freeradius-3.0.1-6.el7.x86_64 : High-performance and highly configurable free
: RADIUS server
Repo : aa
Matched from:
Filename : /etc/raddb/mods-available/smbpasswd
samba-client-4.1.1-31.el7.x86_64 : Samba client programs
Repo : aa
Matched from:
Filename : /usr/bin/smbpasswd
[root@system1 /]#yum install samba-client -y
[root@system1 /]# id andy
uid=1713(andy) gid=1713(andy) groups=1713(andy)
[root@system1 /]#
[root@system1 /]# smbpasswd -a andy
New SMB password:
Retype new SMB password:
Added user andy.
[root@system1 /]# firewall-cmd --add-service=samba --permanent
9.
配置多用户
SMB
挂载
在
system1
共享通过
SMB
目录
/miscellaneous
满足以下要求:
共享名为
miscellaneous
共享目录
miscellaneous
只能被
rhce.cc
域中的客户端使用
共享目录
miscellaneous
必须可以被浏览
用户
silene
必须能以读的方式访问此共享,
访问密码是
redhat
用户
akira
必须能以读写的方式访问此共享,
访问密码是
redhat
此共享永久挂载在
system2.rhce.cc
上的
/mnt/multi
目录
,
并使用用户
silene
作为认证
任何用户可以通过用户
akira
来临时获取写的权限
[root@system1 /]#mkdir /miscellaneous
[root@system1 /]#cat /etc/samba/smb.cnf
添加以下内容:
[miscellaneous]
path=/miscellaneous
hosts allow=192.168.122.0/24
writable=no
write list=akira
[root@system1 /]#useradd silene
[root@system1 /]#useradd akira
[root@system1 /]#smbpasswd –a silene
[root@system1 /]#smbpasswd –a akira
[root@system1 /]#systemctl restart smb
[root@system1 /]#systemctl enable smb
[root@system2 /]#mkdir /mnt/multi
[root@system1 /]#yum install cifs* smba-client* -y
[root@system2 /]#smbclient –L //system1.rhce.cc –U
[root@system1 /]#chmod o+w /miscellaneous/
[root@system1 /]#chcon –R –t samba_share_t /miscellaneous/
[root@system2 /]#mount –o multiuser,sec=ntlmssp,username=silene,password=redhat //system1.rhce.cc/miscellaneous /mnt/multi/
[root@system2 /]#useradd tom1
[root@system2 /]#su – tom1
[root@system2 /]#cd /mnt/multi
[root@system2 /]#cifscreds add system1.rhce.cc –u akira
[root@system2 /]#cat /etc/fstab
添加以下内容:
//system1.rhce.cc/miscellaneous /mnt/multi cifs defaults,multiuser,sec=ntlmssp,username=silene,password=redhat 0 0
[root@system1 /]#firewall-cmd –add-serivce=smtp
[root@system1 /]#firewall-cmd –add-serivce=smtp –permanent
10.
配置
NFS
服务
在
system1
配置
NFS
服务,要求如下
:
以只读的方式共享目录
/public
同时只能被
rhce.cc
域中的系统访问
以读写的方式共享目录
/protected
能被
rhce.cc
域中的系统访问
访问
/protected
需要通过
Kerberos
安全加密,
您可以使用下面
URL
提供的密钥
目录
/protected
应该包含名为
confidential
拥有人为
ldapuser11
的子目录
用户
ldapuser11
能以读写方式访问
/protected/confidential
[root@system1 /]#firewall-cmd –get-services | grep nfs
[root@system1/]#firewall-cmd –add-rich-rule ‘rule family=ipv4 source address=192.168.122.0/24 service name=nfs accept’ --permanent
[root@system1/]#firewall-cmd –add-rich-rule ‘rule family=ipv4 source address=192.168.122.0/24 service name=rpc-bind accept’ --permanent
[root@system1/]#firewall-cmd –add-rich-rule ‘rule family=ipv4 source address=192.168.122.0/24 service name=mountd accept’ --permanent
[root@system1/]#mkdir /public
[root@system1/]#mkdir /protected
[root@system1/]#cat /etc/exports
/public *(ro,sync)
/protected *(rw,sync,sec=krb5p)
[root@system1/]#
[root@system1/]#cat /etc/sysconfig/nfs
RPCNFSDARGS=”-V 4.2”
[root@system1/]#mkdir /protected/confidential
[root@system1/]#chown ldapuser11 /protected/confidential
[root@system1/]#chcon –R –t public_content_t /protected/confidential
[root@system1/]#systemctl start nfs-server
[root@system1/]#systemctl start nfs
[root@system1/]#systemctl start nfs-secure-server
[root@system1/]#system enable nfs-server
11.
挂载一个
NFS
共享
在
system2
上挂载一个来自
system1.rhce.cc
的
NFS
共享,
并符合下列要求:
/public
挂载在下面的目录上
/mnt/nfsmount
/protected
挂载在下面的目录上
/mnt/nfssecure
并使用安全的方式,密钥下载
URL
如
用户
ldapusre11
能够在
/mnt/nfssecure/confidential
上创建文件
这些文件系统在系统启动时自动挂载
[root@system2/]#show mount system1.rhce.cc
[root@system2/]#showmount –e system1.rhce.cc
[root@system2/]#mkdir /mnt/nfsmount
[root@system2/]#mkdir /mnt/nfssecure
[root@system2/]#cat /etc/fstab
system1.rhce.cc:/public /mnt/nfsmount nfs defaults 0 0
[root@system2/]#systemctl start nfs-secure
[root@system2/]#systemctl enable nfs-secure
[root@system2/]#cat /etc/fstab
system1.rhce.cc:protected /mnt/nfssecure nfs defaults,sec=krb5p,v4.2 0 0
[root@system2/]#mount -a
[ldapuser11@system2/]#cd /mnt/nfssecure
[ldapuser11@system2/]#touch ldapuser1111
12.
配置
web
站点
下载文件,并且将文件重命名为
index.html
不要修改此文件的内容
将文件
index.html
拷贝到您的
web
服务器的
DocumentRoot
目录下
来自于
rhce.cc
域的客户端可以访问此
Web
服务
[root@system1/]#yum groupinstall web* -y
[root@system1/]#cat /etc/httpd/conf/httpd.conf
ServerName system1.rhce.cc:80
[root@system1/]#firewall-cmd --add-rich-rule ‘rule family=ipv4 source address=192.168.122.0/24 service name=http accept’ –permanent
[root@system1/]#cat /etc.resolv.conf
Search rhce.cc
Nameserver 192.168.122.10
[root@system1/]#systemctl start httpd
[root@system1/]#systemctl enable httpd
13.
配置安全
web
服务
[root@system1/]#cp /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/vhosts.conf
[root@system1/]#cat /etc/httpd/conf.d/vhosts.conf
<VirtualHost system1.rhce.cc:80>
DocumentRoot /var/www/html
ServerName system1.rhce.cc
</VirtualHost>
<VirtualHost system1.rhce.cc:443>
DocumentRoot /var/www/html
ServerName system1.rhce.cc
SSLEngine on
SSLCertificateFile /ca/system1.crt
SSLCertificateKeyFile /ca/system1.key
SSLCertificateChainFile /ca/domain11.crt
</VirtualHost>
//
以上内容从/etc/httpd/conf.d/ssl.conf
中提取
[root@system1/]#cat /etc/httpd/conf/httpd.conf
SSLEngine off
[root@system1/]#mkdir /ca
[root@system1/]#cd /ca
[root@system1/]#chcon –R --reference=/var/www/html /ca
[root@system1/]#firewall-cmd --add-rich-rule ‘rule family=ipv4 source address192.168.122.0/24 service name=https accept’ --permanent
[root@system1/]#systemctl restart httpd
[root@system1/]#systemctl enable httpd
14.
配置虚拟主机
执行下述步骤:
设置
DocumentRoot
为
/var/www/virtual
下载文件并重命名为
index.html
不要对文件
index.html
的内容做任何修改
将文件
index.html
放到虚拟主机的
DocumentRoot
目录下
确保
andy
用户能够在
/var/www/virtual
目录下创建文件
[root@system1/]#mkdir /var/www/virtual
[root@system1/]#ls –ldZ /var/www/virtual/
[root@system1/]#restorecon –R /var/www/virtual
[root@system1/]#cat /etc/httpd/conf.d/vhosts.conf
添加以下内容:
DocumentRoot /var/www/virtual
</VirtualHost>
<Directory “/var/www/virtual”>
AllowOverride None
Require all granted
</Directory>
[root@system1/]#systemctl restart httpd
[root@system1/]#setfacl –m u:andy:rwx /var/www/virtual
15.
配置
web
内容的访问
在您的
system1
上的
web
服务器的
DocumentRoot
目录下
创建一个名为
secret
的目录,
要求如下:
为
index.html
。
不要对这个文件的内容做任何修改。
从
system1
上,任何人都可以浏览
secret
的内容,
但是从其它系统不能访问这个目
录的内容
[root@system1/]#mkdir /var/www/html/secret
[root@system1/]#mkdir /var/www/virtual/secret
[root@system1/]#cat /etc/httpd/conf.d/vhosts.conf
添加以下内容:
<Directory “/var/www/virtual/secret”>
AllowOverride None
Require local
</Directory>
<Directory “/var/www/html/secret”>
AllowOverride None
Require local
</Directory>
[root@system1/]#systemctl restart httpd
16.
实现动态
Web
内容
在
system1
上配置提供动态
Web
内容,要求如下:
动态内容由名为
dynamic.rhce.cc
的虚拟主机提供
虚拟主机侦听在端口
8998
论如何不要求修改此文件的内容
[root@system1/]#cat /etc/httpd/conf.d/vhosts.conf
添加以下内容:
<VirtualHost dynamic.rhce.cc:8998>
ServerName dynamic.rhce.cc
WSGIScriptAlias / /var/www/html/webapp.wsgi
</VirtualHost>
[root@system1/]#cat /etc/httpd/conf/httpd.conf
添加以下内容:
Listen 8998
[root@system1/]#yum whatprovides */semanage
[root@system1/]#yum install policycoreutils-python* -y
[root@system1/]#yum install mod_wsgi -y
[root@system1/]#semanage port –a –t http_port_t –p tcp 8998 //
命令从/etc/ssh/sshd_config
获得
[root@system1/]#systemctl restart httpd
[root@system1/]#firewall-cmd –add-rich-rule ‘rule family=ipv4 source address=192.168.122.0/24 port port=8998 protocol=tcp accept’ –permanent
17.
创建一个脚本
在
system1
上创建一个名为
/root/script
的脚本,
让其提供下列特性:
当运行
/root/script foo
,输出为
bar
当运行
/root/script bar
,输出为
foo
当没有任何参数或者参数不是
foo
或者
bar
时,
其错误输出产生以下的信息:
/root/script foo|bar
[root@system1/]#cat /root/script
#!/bin/bash
Case $1 in
foo)
echo ‘bar’;;
bar)
echo ‘foo’;;
*)
echo ‘/root/script foo|bar’
exit 1
esac
[root@system1/]#chmod +x script
18.
创建一个添加用户的脚本
在
system1
上创建一个脚本,名为
/root/mkusers ,
此脚本能实现为系统
system1
创建本地
用户
,
并且这些用户
的用户名来自一个包含用户名列表的文件。同时满足下列要求:
此脚本要求提供一个参数,此参数就是包含用户名列表的文件
如果没有提供参数,此脚本应该给出下面的提示信息
Usage: /root/mkusers
然后退出并
返回相应的值
如果提供一个不存在的文件名,此脚本应该给出下面的提示信息
Input file not found
然
后退出并返回相应的值
创建的用户登录
shell
为
/bin/false
此脚本不需要为用户设置密码
[root@system1/]#cat userlist
lisi
wangw
zhaos
liun
[root@system1/]#cat /root/mkusers
#!/bin/bash
If [$# -eq 0]; then
echo ‘Usage: /root/mkusers’
exit 1
fi
if [! –e $1]; then
echo ‘Input file not found’
exit 1
fi
while read line
do
useradd –s /bin/false $line
done <$1
[root@system1/]#chmod +x mkusers
19.
配置
iSCSI
服务端
并符合下列要求:
服务端口为
3260
使用
iscsi_vol
作其后端卷
其大小为
3G
此服务只能被
system2.rhce.cc
访问
[root@system1/]#yum install target* –y
[root@system1/]#systemctl start target
[root@system1/]#systemctl enable target
[root@system1/]#netstat –ntulp | grep 3260
[root@system1/]#firewall-cmd –add-rich-rule ‘rule family=ipv4 source address=192.168.122.200 port port=3260 protocol accept’ –permanent
[root@system1/]#fdisk /dev/vda
[root@system1/]#p->n->e->+3G->w
[root@system1/]#partprobe /dev/vda
[root@system1/]#targetcli
/>/backstores/block create iscsi_vol /dev/vda5
/>luns/ create /backstores/block/iscsi_vol
/>portals/ create 192.168.122.100 3260
[root@system1/]#netstat –ntulp | grep 3260
[root@system1/]#systemctl restart target
[root@system1/]#systemctl restart targetd
[root@system1/]#systemctl enable target
[root@system1/]#systemctl enable targetd
20.
配置
iSCSI
的客户端
并符合以下要求:
iSCSI
设备在系统启动的期间自动加载
块设备
iSCSI
上包含一个大小为
1700 MiB
的分区,并格式化为
xfs
此分区挂载在
/mnt/data
上同时在系统启动的期间自动挂载
[root@system2/]#yum list iscsi*
[root@system2/]#yum install iscsi-initiator-utils.x86_64 –y
[root@system2/]#cat /etc/iscsi/initiatorname.iscsi
[root@system2/]#systemctl restart iscsid
[root@system2/]#systemctl enable iscsid
[root@system2/]#iscsiadm –m discovery –t st –p 192.168.122.100
[root@system1/]#firewall-cmd --list-all
[root@system1/]#firewall-cmd –-remove-rich-rule ‘rule family=”ipv4” source address=”192.168.122.200” port port=”3260” protocol=”tcp” accept’ –permanent
[root@system1/]#firewall-cmd --add-rich-rule ‘rule family=”ipv4” source address=”192.168.122.200” port port=”3260” protocol=”tcp” accept’ –permanent
[root@system2/]#fdisk /dev/sda
p->n->+1700M->p->w
[root@system2/]#partprobe /dev/sda
[root@system2/]#mkfs.xfs /dev/sda1
[root@system2/]#mkdir /mnt/data
[root@system2/]#cat /etc/fstab
/dev/sda1 /mnt/data xfs defaults,_netdev 0 0
[root@system2/]#mount –a
21.
配置一个数据库
在
system1
上创建一个
MariaDB
数据库
,
名为
Contacts
,并符合以下条件:
数
据
库
应
该
包
含
来
自
数
据
库
复
制
的
内
容
,
复
制
文
件
的
URL
为
数据库只能被
localhost
访问。
除了
root
用户
,
此数据库只能被用户
Luigi
查询。
此用户密码为
redhat
。
root
用户的密码为
redhat
,
同时不允许空密码登录。
[root@system1/]#yum install mariadb-server mariadb -y
[root@system1/]#systemctl start mariadb
[root@system1/]#systemctl enable mariadb
[root@system1/]#mysql
->create database Contacts;
->source /root/users.mdb;
->grant select on Contacts.* to Luigi@’localhost’ identified by ‘redhat’;
->set password=password(‘redhat’);
[root@system1/]#mysql –uroot –predhat
22.
数据库查询
在系统
system1
上使用数据库
Contacts,
并使用相应的
SQL
查询以回答下列问题:
密码是
tangerine
的人的名字
?
有多少人的姓名是
John
同时居住在
Santa Clara?
[root@system1/]#mysql –uroot –predhat
->use Contacts
->select * from name join pass where name.aid=pass.bid and password=’ tangerine’;
->select count(*) from name join loc where name.aid=loc.cid and firstname=’John’ and loc.loction=’Santa Clara’;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26366371/viewspace-2673118/
,如需转载,请注明出处,否则将追究法律责任。