#service NetworkManager stop
#chkconfig NetworkManager off
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
修改ONBOOT=yes
#service network restart
#iptables –F
#service iptables save
配置YUM源
#vim /etc/yum.repos.d/rhel-source.repo
1.确认SELinux处于enforcing状态。
#vim /etc/selinux/config
2.请将ip forward 功能打开,并且永久生效。
#vim /etc/sysctl.conf
将此句改成启用状态net.ipv4.ip_forward=1
3.配置cron 权限,sarah用户不能使用cron, 其他用户不受影响。
#vim /etc/cron.deny
将sarah用户名写入其中即可
4.为station.domain60.example.com实施一个ftp服务,并且满足下面要求:允许匿名用户从/var/ftp/pub目录下载文件。
domain60.example.com域以外的用户不能够访问你的ftp服务。
#yun install vsftpd -y
#chkconfig vsftpd on
#service vsftpd start
#iptables -A INPUT ! -s 172.24.60.0/24 -p tcp -- dport 21 -j REJECT
#iptables -nL (查看已经设置过的规则)
5.配置你的系统以提供SMTP邮件服务,并且满足下列要求:
你的邮件服务器必须能够接收来自远程主机的和本地的邮件。
harry用户能够接收邮件从远程主机发送来的邮件,并且投递给harry的邮件放在harry的默认邮箱/var/spool/mail/harry。
#vim /etc/postfix/main.cf
开启inet_interfaces=all
注释inet_interfaces=localhost
#service postfix restart
#chkconfig postfix on
#netstat -tunalp | grep :25 (查看更改后端口是否监听所有)
#echo “this is test email” | mail -s test harry (-s 表示subject)
#su - harry (切换用户测试是否收到邮件)
#mail
6.配置一个电子邮件别名,发送给admin的邮件都被本地natasha接收。
#vim /etc/aliases
写入admin: natasha (如果多用户,用逗号隔开)
#service postfix restart
7.使用SMB共享目录/common:
你的samba服务器必须是STAFF工作组的成员。
共享名为common。
common只对domain60.example.com域里的客户端可用。
common必须可以浏览。
harry用户能够访问和读写这个共享,如果需要的话使用密码indionce进行验证。
#yum install samba -y
#chkconfig smb on
#vim /etc/samba/smb.conf
workgroup=STAFF
[common]
path = /common
browseable=yes (可浏览)
writable=yes (可读写)
write list=harry
hosts allow=172.24.60. (只允许这个域访问)
#mkdir /common
#chcon -t samba_share_t /common (在/etc/samba/smb.conf中有该提示语句)
#chmod o+w /common (查看该文件夹的其他组权限并作修改,若有文件则需要加-R)
#smbpasswd -a harry (该用户必须是系统中存在的用户。密码indionce)
# service smb restart
#smbclient //station.domain60.example.com/common -U harry
#登录成功后使用put和get测试是否可以上传和下载
8.通过NFS向domain60.example.com域共享/common目录。
#vim /etc/exports
/common 172.24.60.0/24(rw,sync)
#chkconfig rpcbind on
#chkconfig nfs on
#service rpcbind restart (和nfs有依赖关系,需要先启动rpcbind)
#service nfs restart
#showmount -e 172.24.60.10 (检查是否共享成功)
9.配置SSH访问,并且满足下列要求:
haryy用户在domain60.example.com域中可以使用SSH访问你的机器。所有在t3gg.com域中的客户端不能通过SSH访问你的机器。
#iptables -A INPUT -s 172.24.60.0/24 -p tcp --dport 22 -j ACCEPT
#iptables -A INPUT -s 172.25.0.0/16 -p tcp --dport 22 -j REJECT
#service iptables save
10.为站点station.domain60.example.com实施一个web服务:
下载ftp://server.domain60.example.com/pub/materials/stationX.html并放置到本机的DocumentRoot目录, 重命名为index.html, 不要对文件内容做任何修改。
#yum install httpd -y
#chkconfig httpd on
#service httpd start
#wget ftp://server.domain60.example.com/pub/materials/stationX.html
#cp stationX.html /var/www/html/index.html
#restorecon -R /var/www/html
11.扩展你的web服务,包含一个名为www.domain60.example.com的虚拟主机站点,要求如下:
设置DocumentRoot为/var/www/virtual。
下载ftp://server.domain60.example.com/pub/materials/wwwX.html并放置到DocumentRoot目录,重命名为index.html, 对文件内容不要做任何修改。注意:原有的station.domain60.example.com必须可以继续访问。
DNS服务器已经提供了对www.domain60.example.com的解析。
#vim /etc/httpd/conf/httpd.conf
NameVirtualHost *:80 (配置文件中需要开启这一行)
<VirtualHost *:80>
ServerName www.domain60.example.com
DocumentRoot /var/www/virtual1/
</VirtualHost>
<VirtualHost *:80>
ServerName station.domain60.example.com
DocumentRoot /var/www/html/
</VirtualHost>
#mkdir /var/www/virtual
#wget ftp://server.domain60.example.com/pub/materials/wwwX.html
#cp wwwX.html /var/www/virtual/index.html
#restorecon -Rv /var/www/virtual
#service httpd restart
#chkconfig httpd on
12.配置web服务,在你的服务器的/var/www/virtual目录下创建名字为confidential的目录,
下载ftp://server.domain60.example.com/pub/materials/confidential.html到目录中并重命名为index.html,此目录只允许本地系统访问,不能够被其他系统访问。
在你的服务器的/var/www/html 目录下创建名字为secret目录,下载ftp://server.domain60.example.com/pub/materials/secret.html到目录中并重命名为index.html,此目录要求本地用户进行密码验证登陆。
#mkdir /var/www/virtual/confidential
#wget ftp://server.domain60.example.com/pub/materials/confidential.html
#cp confidential.html /var/www/virtual/confidential/index.html
#restorecon -Rv /var/www/virtual
#vim /etc/httpd/conf/httpd.conf
写入<Directory “/var/www/virtual/confidential”>
Order allow,deny
Allow from 127.0.0.1 172.24.60.10
</Directory>
#service httpd restart (confidential目录权限设置完成)
#mkdir /var/www/html/secret
#wget ftp://server.domain60.example.com/pub/materials/secret.html
#cp secret.html /var/www/html/secret/index.html
#vim /etc/httpd/conf/httpd.conf
写入<Directory “/var/www/html/secret”>
AuthName “this is secret page”
AuthType basic
AuthUserFile /etc/httpd/.htpasswd
require valid-user
</Directory>
#htpasswd -c /etc/httpd/.htpasswd student (创建web相关的用户和密码)
#service httpd restart
#chkconfig httpd on
13.创建一个脚本/root/script.sh并且要求如下:
当运行/root/script.sh all输出的结果为none
当运行/root/script.sh none输出的结果为all
当没有参数或者输入除all 或none之外参数时候输出: usage: /root/script.sh all| none
#vim /root/script.sh
写入
#!/bin/bash
case $1 in
all)
echo none;;
none)
echo all;;
*)
echo “all|none”;;
esac
或者
#!/bin/bash
if[[$1 = all]] ; then
echo none
elif[[$1=none]];then
echo all
else
Echo “all|none”
fi
# chmod a+x /root/script.sh (将script.sh的所有文件都加上x权限)
# ./script.sh (显示all|none)
# ./script.sh all (显示none)
# ./script.sh none (显示all)
14.下载ftp://server.domain60.example.com/pub/materials/root.iso, 要求在开机的时候此iso文件能够自动挂载到/mnt/image目录。
#wget ftp://server.domain60.example.com/pub/materials/root.iso
#mkdir /mnt/image
#vim /etc/fstab
写入/root/root.iso /mnt/image iso9660 defaults,loop 0 0
#mount -a
#df -TH (查看挂载情况)
15.修改你的系统,在启动的时候设置内核参数kernctl为5。可以通过/proc/cmdline观察到此内核参数。
#vim /boot/grub/grub.conf
将kernel一行最后的quiet字段后面写入 kernctl=5
#reboot
#cat /proc/cmdline
16.系统host.domain60.example.com通过标准的iSCSI端口提供了一个iSCSI设备。
配置你的系统连接到此设备并按如下要求创建文件系统:
创建一个500MiB的分区并且格式化成ext4文件系统,此分区要求挂载到/mnt/data目录, 并且在开机时候能够自动挂载。此文件系统上包含
ftp://server.domain60.example.com/pub/materials/iscsi.txt文件的副本。文件的所有者是root, 权限为0644,不要对文件内容做任何修改。
# yum install iscsi-init* -y
# iscsiadm -m discovery -t sendtargets -p host.domain60.example.com (查找iSCSI Target端所提供的设备)
显示
Starting iscsid:
172.24.60.254:3260,1 iqn.2014-07.com.example:station60.storage
#iscsiadm -m node -T iqn.2014-07.com.example:station60.storage -p server.domain60.example.com --login (登陆/绑定iSCSI上的目标设备)
#fdisk -cu /dev/sdb (创建一个500M大小的分区)
#partx -a /dev/sdb (执行2次即可看到新的分区)
#mkfs -t ext4 /dev/sdb2
#mkdir /mnt/data
#blkid /dev/sdb2 (将看到的UUID复制下来)
#vim /etc/fstab
写入
UUID=“xxxx-xxxx-xxxx-xxxx” /mnt/data ext4 _netdev 0 0
#mount -a (自动挂载/etc/fstab中未挂载的分区)
#df -TH (查看目录的挂载情况)
#wget ftp://server.domain60.example.com/pub/materials/iscsi.txt
#cp iscsi.txt /mnt/data
#chmod 644 /mnt/data/iscsi.txt
【Linux】各个服务的配置命令
最新推荐文章于 2022-05-14 23:43:37 发布