day7 RHCE

 

6、配置本地邮件服务

 在系统server0和desktop0上配置邮件服务,满足以下要求:
这些系统不接收外部发送来的邮件
这些系统上本地发送的任何邮件都会自动路由到 classroom.example.com
从这些系统上发送的邮件都显示来自 example.com
你可以通过发送邮件到本地用户student来测试你的配置,classroom.example.com 已经配置好。
把此用户的邮件转到下列URL http://classroom.example.com/cgi-bin/recevied_mail

[root@server0 ~]# yum install postfix -y

[root@server0 ~]# vim /etc/postfix/main.cf 
99 myorigin = example.com         #来源      显示来自于example.com
115 inet_interfaces = loopback-only       # 接口         只侦监听本地回环的邮件
165 mydestination =                     #本地不接受邮件
195 local_transport = error:local delivery disabled      # 报错   本地不转发
265 mynetworks = 127.0.0.0/8,[::1]/128             #我的本机网段
315 relayhost = [classroom.example.com]              #路由到


[root@server0 ~]# firewall-cmd --permanent --add-service=smtp 
[root@server0 ~]# firewall-cmd --reload 

[root@server0 ~]# systemctl enable postfix
[root@server0 ~]# systemctl restart postfix


[root@server0 ~]# mail -s 'test' student@classroom.example.com
this is the first
EOT

[root@server0 ~]# curl http://classroom.example.com/cgi-bin/recevied_mail
[root@server0 ~]# curl http://classroom.example.com/cgi-bin/recevied_mail |grep "test"

  

 

8、通过SMB共享目录

在server0上配置SMB服务
     您的SMB服务器必须是STAFF工作组的一个成员
  共享/common目录,共享名必须为common
  只有 example.com 域内的客户端可以访问common共享
  Common必须是可以浏览的
  用户rob,samba密码为redhat , 只读权限访问common共享。
  用户brian,samba密码为redhat ,读写权限访问common共享。
  备注: 考试的时候,用户和密码请根据题目实际情况进行设定,有的时候,题目简单一些,测试用户早已建立,有的时候,题目较难一些,用户和密码都必须自己设定

server
[root@server0 ~]# yum install samba samba-client.x86_64 -y

[root@server0 ~]# id rob
[root@server0 ~]# useradd -s /sbin/nologin rob
[root@server0 ~]# useradd -s /sbin/nologin brian       samba用户,不可登录
[root@server0 ~]# smbpasswd -a rob               add samba用户密码
password:redhat
[root@server0 ~]# smbpasswd -a brian
password:redhat

[root@server0 ~]# vim /etc/samba/smb.conf 
		[global]
		---
		workgroup = STAFF     #SMB服务器必须是STAFF工作组的一个成员
		--- 
		security = user       
 		passdb backend = tdbsam    用户数据库

                [common]
                path = /common            共享/common目录
                hosts allow = 172.25.0.       example.com 域内可以访问
                browseable = yes           必须是可以浏览的
                write list = brian      写入权限账号列表 列表中的账号允许写入



[root@server0 ~]# mkdir -pv /common

[root@server0 ~]# chmod 777 /common/

[root@server0 ~]# ll -Z /common/ -d            查看上下文
[root@server0 ~]# ll -Z /etc/samba/ -d
[root@server0 ~]# chcon -t samba_share_t /common/
                                       type



[root@server0 ~]# systemctl restart smb  nmb
[root@server0 ~]# systemctl enable smb nmb

[root@server0 ~]# firewall-cmd --permanent --add-service=samba
[root@server0 ~]# firewall-cmd --reload 
[root@server0 ~]# firewall-cmd --list-all       

  

9、配置多用户SMB挂载

在desktop0上完成以下要求的配置:
  desktop0把server0的common共享通过多用户的方式挂载到本地的/mnt/multiuser (实际的共享和挂载点请根据考试题目设定)
  用户rob,samba密码为redhat , 只读权限访问common共享。
  用户brain,samba密码为redhat ,读写权限访问common共享。
  该共享要求在系统启动时自动挂载。

desktop0
[root@desktop0 ~]# yum install cifs-utils -y    网络文件共享系统CIFS

[root@desktop0 ~]# mkdir -pv /mnt/multiuser 

[root@desktop0 ~]# vim /root/user.txt 挂载时所用到的用户文件 username=brian password=redhat [root@desktop0 ~]# vim /etc/fstab //server0/common /mnt/multiuser cifs credentials=/root/user.txt,multiuser,sec=ntlmssp 0 0 server0的common共享 挂载到本地的/mnt/multiuser 文件系统格式cifs                   credentials 认证信息 指定挂载时所用到的用户文件                                       多用户                                           认证方式为标准smb认证方式 [root@desktop0 ~]# mount -a [root@desktop0 ~]# mount [root@desktop0 ~]# df -h    ####如果题目要求能够访问用户的家目录,做如下设置 [root@desktop0 ~]# getsebool -a | grep samba [root@desktop0 ~]# setsebool -P samba_enable_home_dirs on

  

  #测试多用户挂载

rob用户只读权限,没有写权限
[root@desktop0 ~]# su - rob
[rob@desktop0 ~]$ cifscreds add server0
        redhat
[rob@desktop0 ~]$ ll /mnt/multiuser/
[rob@desktop0 ~]$ touch /mnt/multiuser/robfile
         Permission denied
[rob@desktop0 ~]$ exit


brian用户读写权限
[root@desktop0 ~]# su - brian
[brian@desktop0 ~]$ cifscreds add server0
Password: 
[brian@desktop0 ~]$ ll /mnt/multiuser/
[brian@desktop0 ~]$ touch /mnt/multiuser/brianfile
[brian@desktop0 ~]$ exit


[root@desktop0 ~]# umount /mnt/multiuser
[root@desktop0 ~]# mount
[root@desktop0 ~]# mount -a


brian用户把权限给rob
[root@desktop0 ~]# su - rob
[rob@desktop0 ~]$ cd /mnt
[rob@desktop0 mnt]$ ls
ls: cannot access multiuser: Permission denied
[rob@desktop0 mnt]$ cifscreds add server0 -u brian      
Password: 
[rob@desktop0 mnt]$ cd /mnt/multiuser/
[rob@desktop0 multiuser]$ touch robfile2
[rob@desktop0 multiuser]$ ll /mnt/multiuser/
[rob@desktop0 multiuser]$ exit

  

 

posted @ 2017-10-19 21:32  venicid  阅读(348)  评论(0编辑  收藏  举报