0.考前准备
清空iptables并保存状态,填加两条富规则,允许本域所有流量,拒绝敌对域所有流量,使之永久生效
iptables -F
service iptables save
firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=172.25.0.0/24 accept"
firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=172.26.0.0/24 reject"
firewall-cmd --reload
1.配置SELinux
描述:SELinux必须在两个系统system1和system2中运行于enforcing模式
vim /etc/selinux/config
2.配置SSH访问
描述:domain1.example.com域内客户端能访问,my133t.org域内客户端不能访问
vim /etc/hosts.allow
sshd : 172.25.0.0/24
vim /etc/hosts.deny
sshd : 172.26.0.0/24
3.自定义用户环境
描述:创建命令别名,运行qstat将执行"/bin/ps -Ao pid,tt,user,fname,rsz"
两个系统都做
vim /etc/profile
alias 命令别名="/bin/ps -Ao pid,tt,user,fname,rsz"
source /etc/profile
4.配置端口转发
描述:在system1上配置,把访问5423端口的流量转发到80端口
firewall-config
tcp,udp都做
点击加载
5.配置链路聚合
描述:在system1和system2之间按以下要求配置一个链路
此链路使用接口eth1和eth2
此链路在一个接口失效时仍然能工作
system1使用172.16.1.25/24,system2使用172.16.1.35/24
此链路在系统重启之后依然保持正常状态
两个系统都做
nm-connection-editor
添加team,添加网卡,选定开机自动启动,指定team的ipv4地址
{"runner":{"name":"activebackup"}}
systemctl restart network
ping测试
6.配置ipv6地址
描述:在您的考试系统上配置接口eth0使用下列ipv6地址
system1使用2001:ac18::10a/64
system2使用2001:ac18::114/64
重启后必须生效,保持ipv4依然能通信
两个系统都做
nm-connection-editor
systemctl restart network
ping6测试
7.配置本地邮件服务
描述:在system1和system2上配置邮件服务,满足以下要求
这些系统不接受外部发送来的邮件
在这些系统上本地发送的任何邮件都会自动路由到rhgls.domain1.example.com
从这些系统上发送的邮件显示来自于domain1.example.com
您可以通过发送邮件到本地用户dave来测试您的配置,系统rhgls.domain1.example.com已经配置把此用户的邮件转发到下列url http://rhgls.domain1.example.com/received_mail/1
两个系统都做
vim /etc/postfix/main.cf
local_transport = error:local
relayhost = 转发到
myorigin = 来自于
8.通过smb共享目录
描述:在system1上配置smb服务
您的smb服务器必须是staff工作组的一个成员
共享/common目录,共享名必须为common
只有domain1.example.com域内的客户端可以访问common共享
common必须是可以浏览的
用户andy必须能够读取共享中的内容,如果需要的话,验证的密码是shabi
system1配置
yum install -y samba samba-client
systemctl enable smb nmb
systemctl restart smb nmb
mkdir /common
vim /etc/samba/smb.conf
workgroup = STAFF
[common]
path = /common
hosts allow = 172.25.0.
browseable = yes
semanage fcontext -a -t samba_share_t /common
restorecon -Rv /common
pdbedit -a andy
system2验证
yum install -y samba-client cifs-utils
smbclient -L //172.25.0.11 -U andy
9.配置多用户smb挂载
描述:在system1共享通过smb目录/miscellaneous满足以下要求:
共享名为miscellaneous
共享目录miscellaneous只能被domain1.example.com域中的客户端使用
共享目录miscellaneous必须可以被浏览
用户silene必须能以读的方式访问此共享,访问密码是shabi
用户akira必须能以读写的方式访问此共享,访问密码是shabi
此共享永久挂载在system2.domain.example.com上的/mnt/multi目录,并使用用户silene作为认证
任何用户可以通过用户akira来临时获取写的权限
system1配置
mkdir /miscellaneous
chmod o+w /miscellaneous
semanage fcontext -a -t samba_share_t /miscellaneous
restorecon -Rv /miscellaneous
pdbedit -a silene
pdbedit -a akira
vim /etc/samba/smb.comf
[miscellaneous]
path = /miscellaneous
hosts allow = 172.25.0.
browseable = yes
writable = no
write list = akira
systemctl restart smb nmb
system2配置
yum install -y cifs-utils samba-client
mkdir /mnt/multi
chmod o+w /mnt/multi
vim /etc/fstab
//172.25.0.11/miscellaneous /mnt/multi cifs defaults,multiuser,username=silene,password=shabi,sec=ntlmssp 0 0
mount -a
10.配置nfs服务
描述:在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
system1配置
mkdir /public
mkdir -p /protected/confidential
chown deepak /protected/confidential
vim /etc/exports
/public 172.25.0.0/24(ro)
/protected 172.25.0.0/24(rw,sec=krb5p)
wget http://host.domain1.example.com/materials/nfs_server.keytab
mv nfs_server.keytab /etc/krb5.keytab
vim /etc/sysconfig/nfs
RPCNFSDARGS="-V 4.2"
systemctl restart nfs-server nfs-secure-server
systemctl enable nfs-server nfs-secure-server
exportfs -r
11.挂载一个nfs共享
描述:在system2上挂载一个来自system1.domain.example.com的nfs共享,并符合下列要求:
/public挂载在下面的目录上 /mnt/nfsmount
/protected挂载在下面的目录上 /mnt/nfssecure并使用安全的方式,密钥下载url如下:
http://host.domain1.example.com/materials/nfs_client.keytab
用户deepak能够在/mnt/nfssecure/confidential上创建文件
这些文件系统在系统启动时自动挂载
system2配置
showmount -e 172.25.0.11
wget http://host.domain1.example.com/materials/nfs_client.keytab
mv nfs_client.keytab /etc/krb5.keytab
mkdir /mnt/nfsmount
mkdir /mnt/nfssecure
vim /etc/fstab
172.25.0.11:/public /mnt/nfsmount nfs defaults 0 0
172.25.0.11:/protected /mnt/nfssecure nfs defaults,sec=krb5p,v4.2 0 0
systemctl restart nfs nfs-secure
systemctl enable nfs nfs-secure
mount -a
12.实现一个web服务器
描述:在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服务
system1配置
yum install -y httpd
systemctl enable httpd
cp /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/
vim /etc/httpd/conf.d/httpd-vhosts.conf
DocumentRoot /var/www/html
ServerName system1.doamin.example.com
systemctl restart httpd
13.配置安全web服务
描述:为站点http://system1.domail1.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获取
system1配置
yum install -y mod_ssl
cd /var/www/html
wget http://host.domain1.example.com/materials/system1.crt
wget http://host.domain1.example.com/materials/system1.key
wget http://host.domain1.example.com/materials/domain1.crt
vim /etc/httpd/conf.d/httpd-vhosts.conf
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLHonorCipherOrder on
DocumentRoot /var/www/html
ServerName system1.domain1.example.com
SSLCertificateFile /var/www/html/system1.crt
SSLCertificatekeyFile /var/www/html/system1.key
SSLCACertificateFile /var/www/html/domain1.crt
setsebool -P httpd_read_user_content=on
systemctl restart httpd
14.配置虚拟主机
描述:在system1上扩展您的web服务器,为站点http://www.domain1.example.com创建一个虚拟主机,然后执行下述步骤:
设置DocumentRoot为/var/www/virtual
从http://rhgls.domain1.example.com/materials/www.html下载文件并重命名为index.html
将文件index.html放到虚拟主机的DocumentRoot目录下
确保andy用户能够在/var/www/virtual目录下创建文件
system1配置
mkdir /var/www/virtual
setfacl -m u:andy:rwx /var/www/virtual
wget http://rhgls.domain1.example.com/materials/www.html
mv www.html /var/www/virtual
vim /etc/httpd/conf.d/httpd-vhosts.conf
DocumentRoot /var/www/virtual
ServerName system1.domain1.example.com
15.配置web内容的访问
描述:在您的system1上的web服务器的DocumentRoot目录下创建一个名为secret的目录,要求如下
从http://rhgls.domain1.example.com/materials/private.html下载一个文件副本到这个目录,重命名为index.html
从system1上,任何人都可以浏览secret的内容,但是从其它系统不能访问这个目录的内容
system1配置
mkdir /var/www/html/secret
wget http://rhgls.domain1.example.com/materials/private.html
mv private.html /var/www/html/secret/
vim /etc/httpd/conf.d/httpd-vhosts.conf
AllowOverride none
Require local
Require all denied
systemctl restart httpd
16.实现动态web内容
描述:在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域内的所有系统访问
system1配置
yum install -y mod_wsgi
mkdir /var/www/ws
cd /var/www/ws
wget http://rhgls.domain1.example.com/materials/webapp.wsgi
vim /etc/httpd/conf.d/httpd-vhosts.conf
listen 8998
WSGIScriptAlias / /var/www/ws/webapp.wsgi
ServerName dynamic.domain1.example.com
semanage port -a -t http_port_t -p tcp 8998
systemctl restart httpd
17.创建一个脚本
描述:在system1上创建一个名为/root/script的脚本,让其提供下列特性
当运行/root/script foo,输出为bar;当运行/root/script bar,输出为foo
当没有任何参数或者参数不是foo或者bar时,其错误输出产生以下的信息/root/script foo|bar
system1配置
vim /root/script
#!/bin/bash
case $1 in
foo)
echo "bar"
;;
bar)
echo "foo"
;;
*)
echo "/root/script foo|bar"
;;
esac
chmod a+x /root/script
18.创建一个添加用户的脚本
描述:在system1上创建一个脚本,名为/root/mkusers,此脚本能实现为系统system1创建本地用户,并且这些用户的用户名来自一个包含用户名列表的文件,同时满足下列要求
此脚本要求提供一个参数,此参数就是包含用户名列表的文件
如果没有提供参数,此脚本应该给出下面的提示信息Usage:/root/mkusers userfile然后退出并返回相应的值
如果提供一个不存在的文件名,此脚本应该给出下面的提示信息Input file not found然后退出并返回相应的值
创建的用户登录shell为/bin/false,此脚本不需要为用户设置密码
您可以从下面的url获取用户名列表作为测试用http://rhgls.domain1.example.com/materials/userfile
system1配置
cd /root
wget http://rhgls.domain1.example.com/materials/userfile
vim mkusers
#!/bin/bash
if [ $# -eq 0 ] ; then
echo "Usage:/root/mkusers 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
chmod a+x /root/mkusers
19.配置iscsi服务端
描述:配置system1提供一个iscsi服务,磁盘名为iqn.2014-12.com.example.domain1:system1,并符合下列要求
服务端口为3260,使用iscsi_vol作其后端卷,其大小为3G,此服务只能被system2.domain1.example.com访问
system1配置
yum install -y target*
systemctl enable targetd
fdisk /dev/vdb
创建一个3G的逻辑卷
targetcli
cd backstores/block
create disk0 /dev/vdb5
cd ../../iscsi
create iqn.2014-12.com.example.domain1:system1
cd iqn.2014-12.com.example.domain1:system1/tpg1/luns
create /backstores/block/disk0
cd ../acls
create iqn.2014-12.com.example.domain1:system2
cd ../portals
create 172.25.0.11
exit
systemctl restart targetd
20.配置iSCSI的客户端
描述:配置system2十七能连接在system1上提供的iqn.2014-12.comexample.domain1:system1,并符合以下要求
iSCSI设备在系统启动期间自动加载
块设备iSCSI上包含一个大小为1700MiB的分区,并格式化为xfs
此分区在系统启动期间自动挂载到/mnt/data上
system2配置
yum install -y iscsi-*
systemctl enable iscsi
vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2014-12.comexample.domain1:system2
iscsiadm -m discovery -t st -p 172.25.0.11
iscsiadm -m node -T iqn.2014-12.comexample.domain1:system1 -p 172.25.0.11 --login
fdisk /dev/sda
mkfs.xfs /dev/sda5
mkdir /mnt/data
vim /etc/fstab
/dev/sda5 /mnt/data xfs defaults 0 0
systemctl restart iscsi
21.配置一个数据库
描述:在system1上创建一个mariadb数据库,名为contacts,并符合以下条件:
数据库应该包含来自数据库复制的内容,复制文件的url为
http://rhgls.domain1.example.com/materials/users.mdb
数据库只能被localhost访问
除了root用户,此数据库只能被用户Luigi查询,此用户密码为shabi
root用户的密码为shabi,同时不允许空密码登录
system1配置
yum groupinstall -y mariadb mariadb-server
vim /etc/my.cnf
skip-networking=1
systemctl enable mariadb
systemctl restart mariadb
wget http://rhgls.domain1.example.com/materials/users.mdb
mysql
show databases;
create database contacts;
user contacts;
source /root/users.mdb
show tables;
grant select on contacts.* to Luigi@localhost identified by "shabi";
mysql_secure_installation
mysql -u root -p
22.数据库查询
描述:数据库查询,在系统system1上使用数据库contacts,并使用相应的sql查询回答下列问题
密码是tangerine的人的名字
用户id号码为4654的用户名称是
system1
mysql -u root -p
select * from user_logins where user_pass="tangerine";
select * from user_names where user_id="4654"