RHCE 6.0 集訓試題+答案

RHCE (下午2小時)
網絡
設置靜態網絡,要求以下:ip192.168.0.100+X    netmask 255.255.255.0 gateway:192.168.0.254  DNS1:192.168.0.254  DNS2:192.168.1.254 要求每次開機自動激活網卡
FTP&HTTP&NFS
安裝FTP server 匿名用戶能夠從/var/ftp/pub下載
system-config-firewall  disable,容許全部。 disable拒絕全部
yum -y install vsftpd
service vsftpd restart
chkconfig vsftpd on
根在/var/ftp/pub, 匿名用戶 ftpanonymous登陸顯示目錄。 非匿名用戶 登陸顯示用戶的 home目錄
配置HTTP server,經過http//serverX.example.com 能夠訪問,頁面內容能夠從ftp//192.168.0.254/pub/server.html 下載
注意yum倉庫的路徑,ftphttp的根目錄
yum install httpd
chkconfig httpd on
service httpd  restart
service httpd configtest
注意文件的context值,
cd /var/www/html   wget ftp//192.168.0.254/pub/server.htm .
cp server.html index.html
測試:     links http://server9.example.com/
存儲
請掛載iscsi存儲,iscsi servicer192.168.0.254,在該存儲上面分配30m空間,格式化成ext3的根式,掛載在/mnt/storage目錄下,要求每次開機都生效
yum list |grep iscsi
yum -y install iscsi-init*
service iscsi start
iscsi -m discovery -t sendtargets -p 192.168.0.254:3260
iscsi -m node -T iqnname -p 192.168.0.254:3260  -l
fdisk /dev/sda
mkfs.etx3 /dev/sda
mount /dev/sda5 /mnt/storage
寫在開機腳本/etc/fstab 
屬性_netdev
腳本
寫一個腳本/root/myscripts.sh,當用戶輸入/root/myscripts.sh all顯示none,當用戶輸入/root/myscripts.sh none顯示all,執行/root/myscripts.shallnone時候,則顯示"Error,please input all/no"
#/bin/bash
word=$1
if [ $word = all ]
   then echo "none"
   else if [ $word   =   none ]
        then echo "all"
   else
   echo "Error,please input all/none"
fi
f i
Chmod a+x /myscripts.sh 
[$word = none ] 能夠修改成test $word = none  test 命令腳本
共享/mnt/storage目錄。容許example.com域裏面的用戶對該目錄有讀寫權限,remote.test對該用戶僅有隻讀權限。
service nfs restart
chkconfig nfs on
vim /etc/exports
/mnt/storage   *.example.com(rw,sync)
/mnt/storage   *.remote.test(ro,sync)
測試: ssh 192.168.0.16 ; showmount -e 192.168.0.116 ;
容許example.com域中的計算機能夠訪問ssh server 拒絕remote.test域中的計算級訪問ssh server
sshd.example.com
/etc/hosts.allow    sshd: ALL EXCEPT .example.com
/etc/hosts.deny    sshd: .example.com
/etc/hosts.allow /etc/hosts.deny有明確接受先接受,沒有明確接受有明確拒絕就拒絕,沒有明確接受明確拒絕則接受
配置samba,要求以下:
一、 共享/mnt/storage目錄,共享名爲share
二、 僅容許user1,user2用戶對該目錄有寫權限,其餘用戶只讀,密碼爲redhat
三、 僅容許用戶在example.com域能夠訪問該共享
四、 容許全部人瀏覽,拒絕匿名用戶訪問。
yum -y install samba
Service smb restart ;service nmb restart ; chkconfig smb on; chkconfig nmb on;
chcon -t samba_share_t /mnt/storage
getsebool -a | grep samba
setsebool -P samba_domain_controller=1
setsebool -P samba_export_all_ro=1
setsebool -P samba_enable_home_dirs=1
添加samba用戶:首先必須是一個本地用戶: sampasswd -a user1 ;
Netbios name  = RHCE
       [ share ]
       comment = Public Stuff
       path = /mnt/storage
       public = no
       writable = yes
       write list =user1,user2
       browseable = yes
/etc/hosts.deny中添加: samba: ALL EXCEPT .example.com
測試:smbclient -L //192.168.0.116; mount -t cifs 192.168.0.116:/share /samba -o username=user1
配置FTP服務器
一、 創建ftp server 容許匿名用戶能夠上傳,
二、 將全部用戶都鎖定在本身的家目錄
三、 僅容許example.com域用戶訪問該FTP 
yum -y install vsftpd
service vsftpd restart
chkconfig vsftpd on
chmod 777 /var/ftp/pub
man ftpd_selinux
chcon -P -t pubic_content_rw_t /var/ftp/pub
getsebool -a | grep ftp
allow_ftpd_anon_write=1
          
vim /etc/vsftpd/vsftpd.conf
容許匿名用戶能夠上傳: anon_upload_enable=YES write_enable=YES爲前提 
將全部用戶都鎖定在本身的家目錄: chroot_list_enable=YES
僅容許example.com域用戶訪問: vim /etc/hosts.allow  vsftpd:example.com
Vim /etc/hosts.deny  vsftpd:  ALL
測試:
SElinux的狀態設置爲Enforcing模式
yum whatprovides *system-config-selinux
安裝
select-status-system Default Enforcing Mode
新建一臺web server 要求以下:
一、 下載http://192.168.0.254/pub/tools/server.html文中,當用戶輸入http://serverX.example.com能夠訪問該文件,僅容許本機能夠訪問http//serverX.example.com下的pub目錄
NameVirtualHost 192.168.0.116:80
<VirtualHost 192.168.0.116:80>
#    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/virt1
    <Directory /var/www/html/ pub >
    order allow,deny
    deny from all
    allow from 192.168.0.116
#   options Indexes -FollowSymLinks
   Allowoverride  authconfig
    </Directory>
    ServerName server16.example.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
二、 下載http://192.168.0.254/pub/tools/www.html文中,當用戶輸入http://serverX.example.com能夠訪問到該文中的內容,該站點須要身份驗證,僅alicebob能夠訪問,密碼均爲redhat
生成httpd的用戶認證
htpasswd -cm /etc/httpd/.htpasswd alice
htpasswd -m /etc/httpd/.htpasswd bob
NameVirtualHost 192.168.0.116:80
<VirtualHost 192.168.0.116:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/virt2
    ServerName www16.example.com
    <Directory /var/www/html/virt2>
    AuthName "test"
    AuthType basic
    AuthUserFile /etc/httpd/.htpasswd
    require valid-user
    </Directory>
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
新建郵件服務器,要求以下
一、 容許localhost和遠程主機均可以訪問
二、 容許example.com域能夠中繼,拒絕remote.test
三、 全部發送給user3的郵件將發送給user1
四、 僅容許用戶在example.com域中使用pop3接受郵件。
相關文章
相關標籤/搜索