手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

RHCE 模拟题及答案

[日期:2012-06-04] 来源:Linux社区  作者:Linux [字体: ]

RHCE部分


一、 开启SELinux
 SELinux必须是Enforcing状态
[root@ www.linuxidc.com ~]# setup

二、 搭建NFS服务
[root@ www.linuxidc.com ~]# yum -y install nfs-utils
 共享出/data目录
 允许172.16.0.0/16读写方式访问
[root@ www.linuxidc.com ~]# vi /etc/exports
/data     172.16.0.0/16(rw,async)
[root@ www.linuxidc.com ~]# chkconfig nfs on
[root@ www.linuxidc.com ~]# service nfs start

三、 搭建FTP服务
 匿名用户可以访问ftp
 student1和student2登录ftp后,只能在自己的家目录下
 student3不能登录ftp
 允许从example.com这个域来访问
 不允许从cracker.org来访问
[root@ www.linuxidc.com ~]# yum -y install vsftpd
[root@ www.linuxidc.com ~]# vim /etc/vsftpd/vsftpd.conf
 chroot_list_enable=YES
 chroot_list_file=/etc/vsftpd/chroot_list
[root@ www.linuxidc.com ~]# echo 'student1' > /etc/vsftpd/chroot_list
[root@ www.linuxidc.com ~]# echo 'student2' >> /etc/vsftpd/chroot_list
[root@ www.linuxidc.com ~]# echo 'student3' >> /etc/vsftpd/ftpusers
[root@ www.linuxidc.com ~]# getsebool -a | grep ftp
ftp_home_dir --> off
[root@ www.linuxidc.com ~]# setsebool -P ftp_home_dir on
[root@ www.linuxidc.com ~]# vim /etc/hosts. deny
 vsftpd:ALL
[root@ www.linuxidc.com ~]# echo 'vsftpd:172.16.0.0/255.255.0.0' >> /etc/hosts.allow
[root@ www.linuxidc.com ~]# whereis vsftpd
 vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz
[root@ www.linuxidc.com ~]# ldd /usr/sbin/vsftpd | grep libwrap.so
        libwrap.so.0 => /lib/libwrap.so.0 (0x00170000)

测试:分别用student1 student2 student3 student4 登录ftp并查看当前路径

四、 配置samba服务?
 共享出/yangbang目录
 只有172.16.0.0/16和192.168.1.0/24和127.0.0.1可以访问
 共享出的名字是[sharefile],默认可以查看到该共享
 只有student组才有写的权限
 student组成员的家目录也要被共享
 设置Netbios name=GUESTX
[root@ www.linuxidc.com ~]# yum -y install samba
[root@ www.linuxidc.com ~]# vim /etc/samba/smb.conf
  ;       passdb backend = tdbsam  //注释掉这行
  netbios name = GUEST2002   //去掉注释并改名
        [sharefile]
        comment = share file
        path = /yangbang
        browseable = no
        write list = @student
        hosts allow = 172.16.0.0/16 192.168.1.0/24 127.0.0.1
 [root@ www.linuxidc.com ~]# service smb restart
[root@ www.linuxidc.com ~]# chkconfig smb on
[root@ www.linuxidc.com ~]# getsebool -a | grep samba
   samba_enable_home_dirs --> off
[root@ www.linuxidc.com ~]# setsebool -P samba_enable_home_dirs on
[root@ www.linuxidc.com ~]# chgrp student /yangbang/
[root@ www.linuxidc.com ~]# chmod g+w /yangbang/
[root@ www.linuxidc.com ~]# chcon -R -t samba_share_t /yangbang/
[root@ www.linuxidc.com ~]# testparm   //测试samba的配置文件
[root@ www.linuxidc.com ~]# smbclient //192.168.142.200/sharefile -U student       
  Password:
  Domain=[GUEST2002] OS=[Unix] Server=[Samba 3.0.33-3.14.el5]
smb: \> pwd
   Current directory is \\192.168.142.200\sharefile\

五、 搭建ssh服务
 puser用户不能远程登录
 不允许cracker.org这个域的访问
[root@ www.linuxidc.com certs]# whereis sshd
 sshd: /usr/sbin/sshd /usr/share/man/man8/sshd.8.gz
[root@ www.linuxidc.com certs]# ldd /usr/sbin/sshd | grep libwrap.so
    libwrap.so.0 => /lib/libwrap.so.0 (0x0096b000)
[root@ www.linuxidc.com certs]# vim /etc/hosts.deny
 sshd,vsftpd:ALL
[root@ www.linuxidc.com certs]# vim /etc/hosts.allow
 sshd:192.168.142.0/255.255.255.0 192.168.0.0/255.255.255.0
[root@ www.linuxidc.com certs]# vim /etc/ssh/sshd_config
 //增加以下行
  DenyUsers puser
[root@masternis pub]# service sshd restart

六、 搭建web服务
 站点的名字:stationX.example.com
 从172.16.254.254:/var/ftp/pub目录下下载webdoc.gz,解压后,挂载到你的站点的的DocumentRoot下,就能看到一个index.html,不用修改index.html的内容
 保证能默认访问到该文件
[root@ www.linuxidc.com ~]# vim /etc/httpd/conf/httpd.conf 
 NameVirtualHost 172.16.0.100
 <VirtualHost 172.16.0.100>
     ServerAdmin webmaster@station100.example.com
     DocumentRoot /var/www/html
     ServerName station100.example.com
     ErrorLog logs/station100.example.com-error_log
     CustomLog logs/station100.example.com-access_log common
 </VirtualHost>
[root@ www.linuxidc.com ~]# mkdir /web
[root@ www.linuxidc.com ~]# mount 192.168.0.254:/ftp/pub /mnt
[root@ www.linuxidc.com ~]# cp /mnt/webdoc.gz /web
[root@ www.linuxidc.com ~]# gunzip /web/webdoc.gz
[root@ www.linuxidc.com ~]# file /webdoc
  Webdoc : linux rev 1.0 ext2 filesystem data
[root@ www.linuxidc.com ~]# mount -o loop /web/webdoc /var/www/html
[root@ www.linuxidc.com ~]# ls /var/www/html/
[root@ www.linuxidc.com ~]# vim /etc/fstab
#加入下面一行
 /web/webdoc /var/www/html ext2  defaults,loop   0 0
[root@ www.linuxidc.com ~]# restorecon -R /var/www/html/
[root@ www.linuxidc.com ~]# Chcon -R -t httpd_sys_content_t /var/www/html/
[root@ www.linuxidc.com ~]# ll -Z /var/www/html
[root@ www.linuxidc.com ~]# vim /etc/hosts
  172.16.0.100    station100.example.com  station100   //加入该行

[root@ www.linuxidc.com ~]# service httpd restart
[root@ www.linuxidc.com ~]# chkconfig httpd on
……

linux
相关资讯      
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款