备注:今年的Linux操作系统考试已经全部结束,仅作为一个记录和留念
前提:配置环回网卡和环境和nat网卡
1、搭建dns服务器
2、Apache和http服务
3、搭建postfix邮件服务器实现邮件发送
4、搭建vsftpdFTP服务器实现文件上传
题目如下:Smaba服务器不用配置
考试要求在两小时内完成
个人总结面向考试的运维流程,精简了实验指导书部分
如果想使用
1、请将ip地址全改成你自己的
2、邮箱实验中的这个密码也改成你自己的
#从服务器 172.22.0.101 获取 download 脚本
wget --ftp-user=ftp --ftp-password=ftp --preserve-permissions ftp://172.22.0.101/*
#下载对应教师(hd)的考试数据
./download hd 172.22.0.101
cd /home/course
cat linux_exam.txt | grep 3121001551
#提交成绩
./upload 3121001551 172.22.0.101
./getScore 3121001551 172.22.0.101
#配置换回网卡
#检查虚拟机设置为桥接
#修改网卡
vi /etc/sysconfig/network-scripts/ifcfg-ens33
ifdown ens33
ifup ens33
#临时关闭selinux
sudo setenforce 0
#关闭防火墙
systemctl stop firewalld
#查看防火墙状态
systemctl status firewalld
DNS
#修改any字段
vi /etc/named.conf
#添加正反区域(需要更改ip)
vi /etc/named.rfc1912.zones
zone "wyulinuxos.com" {
type master;
file "data/wyulinuxos.com.zone";
allow-update { none; };
};
zone "11.30.172.in-addr.arpa" {
type master;
file "data/172.30.11.arpa";
allow-update { none; };
};
#复制模板(改ip)
cp /var/named/named.localhost /var/named/data/wyulinuxos.com.zone;cp /var/named/named.localhost /var/named/data/172.30.11.arpa;chown named.named /var/named/data/wyulinuxos.com.zone;chown named.named /var/named/data/172.30.11.arpa
#修改正向区域(改ip)
vi /var/named/data/wyulinuxos.com.zone
$TTL 1D
wyulinuxos.com. IN SOA dns.wyulinuxos.com. admin.wyulinuxos.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
wyulinuxos.com. IN NS dns.wyulinuxos.com.
dns IN A 172.30.11.1
wyulinuxos.com. IN MX 10 mail4.wyulinuxos.com.
wyulinuxos.com. IN MX 11 www2.wyulinuxos.com.
wyulinuxos.com. IN MX 12 ftp3.wyulinuxos.com.
ftp3 IN A 172.30.11.1
mail4 IN A 172.30.11.1
www2 IN A 172.30.11.1
course IN A 172.30.11.201
#检查正向
named-checkzone wyulinuxos.com /var/named/data/wyulinuxos.com.zone
#配置反向(改ip)
vi /var/named/data/172.30.11.arpa
$TTL 1D
11.30.172.in-addr.arpa. IN SOA dns.wyulinuxos.com. admin.wyulinuxos.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
11.30.172.in-addr.arpa. IN NS dns.wyulinuxos.com.
1 IN PTR dns.wyulinuxos.com.
1 IN PTR ftp3.wyulinuxos.com.
1 IN PTR mail4.wyulinuxos.com.
1 IN PTR www2.wyulinuxos.com.
201 PTR course.wyulinuxos.com.
#检查反向(改ip)
named-checkzone 11.30.172.in-addr.arpa /var/named/data/172.30.11.arpa
#重启dns服务
systemctl restart named
#改dns缓存
vi /etc/resolv.conf
search wyulinuxos.com
nameserver 172.30.11.1
nslookup
Apache
#打开主配置文件
vi /etc/httpd/conf/httpd.conf
#找到修改:
ServerName dns.wyulinuxos.com:80
#末尾添加:(改ip)
NameVirtualHost 172.30.11.201
<VirtualHost course.wyulinuxos.com>
ServerAdmin admin@wyulinuxos.com
DocumentRoot "/var/www/course"
ServerName course.wyulinuxos.com
DirectoryIndex index.html
ErrorLog logs/course/error_log
CustomLog logs/course/access_log combined
</VirtualHost>
#创建日志文件
mkdir -p /var/www/course;echo "hello,course" > /var/www/course/index.html;mkdir -p /etc/httpd/logs/course;touch /etc/httpd/logs/course/error_log;touch /etc/httpd/logs/course/access_log
#重要:(改ip)
ifconfig ens33:3 172.30.11.201 netmask 255.255.255.0
#重启dns和apache
systemctl restart named;systemctl restart httpd
#改dns缓存
vi /etc/resolv.conf
#刷新Windows缓存
ipconfig/flushdns
windows访问
http://course.wyulinuxos.com
linux输入
wget http://course.wyulinuxos.com
postfix
#打开主配置文件
vi /etc/postfix/main.cf
#查找修改
mydestination = $mydomain, $myhostname
#末尾添加
mydomain = wyulinuxos.com
myhostname = dns.wyulinuxos.com
mynetworks = 172.30.11.0/24
myorigin = $mydomain
inet_interfaces = all
relay_domains = wyulinuxos.com
virtual_alias_domains = wyulinuxos.com
virtual_alias_maps = hash:/etc/postfix/virtual
mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#添加两个用户
useradd tom
useradd jerry
#修改密码
passwd tom
passwd jerry
vi /etc/postfix/virtual
#在最末尾添加
all@wyulinuxos.com tom,jerry
vi /etc/aliases
#添加
all: tom,jerry
#输入命令
postmap /etc/postfix/virtual;systemctl restart postfix;postalias /etc/aliases;postfix reload;systemctl start cyrus-imapd;systemctl enable cyrus-imapd
#更改为shadow
vi /etc/sysconfig/saslauthd
MECH=shadow
systemctl start saslauthd;systemctl enable saslauthd
#测试用户密码是否正确
testsaslauthd -u tom -p '*********'
testsaslauthd出现0: NO "authentication failed"的解决方法
在终端下输入命令:setsebool -P allow_saslauthd_read_shadow 1 就可以了
#设置管理员cyrus密码
passwd cyrus
#创建邮件信箱
/usr/bin/cyradm -u cyrus localhost
createmailbox user.tom
createmailbox user.jerry
listmailbox
使用Foxmail创建
用户1
email地址:tom@wyulinuxos.com
显示名称:wyulinuxos(tom)
发信名称:tom@wyulinuxos.com
每隔1分钟定时收取邮件
邮箱类型:POP3
账号:tom@wyulinuxos.com
收件服务器:mail4.wyulinuxos.com 勾选ssl 端口995
发件服务器:mail4.wyulinuxos.com
###如果邮箱创建失败检查一下回环网卡,ping不通的话ifdown ifup一下
用户2
email地址:jerry@wyulinuxos.com
显示名称:wyulinuxos(tom)
发信名称:jerry@wyulinuxos.com
每隔1分钟定时收取邮件
邮箱类型:POP3
账号:jerry@wyulinuxos.com
收件服务器:mail4.wyulinuxos.com 勾选ssl 端口995
发件服务器:mail4.wyulinuxos.com
发送邮件
VSFTPD
解压安装mysql
tar -zxf pam_mysql-0.7RC1.tar.gz -C /tmp/;cd /tmp/pam_mysql-0.7RC1/;./configure --with-pam=/usr --with-mysql=/usr --with-pam-mods-dir=/usr/lib64/security;make;make install
#添加虚拟账户打开mysql
useradd -d /home/virtual -s /sbin/nologin virtual;chmod o+r /home/virtual;systemctl restart mysqld;mysql -u root -p
#创建用户stone并输出
create database ftpdb;use ftpdb;create table ftpusers(name char(20),password char(48));insert into ftpusers(name,password) values ('stone',password('stone'));grant select on ftpdb.ftpusers to virtual@localhost identified by '123456';select * from ftpusers;
#更改vsftpd主配置
vi /etc/vsftpd/vsftpd.conf
#划到底部
#修改
pam_service_name=vsftpd.virtual
xferlog_std_format=NO
#添加,注意不能有空格
guest_enable=YES
guest_username=virtual
allow_writeable_chroot=YES
user_config_dir=/etc/vsftpd/vsftpd_user_conf
#简历pam认证文件
vi /etc/pam.d/vsftpd.virtual
#直接添加
auth required /usr/lib64/security/pam_mysql.so user=virtual passwd=123456 host=localhost db=ftpdb table=ftpusers usercolumn=name passwdcolumn=password crypt=2
account required /usr/lib64/security/pam_mysql.so user=virtual passwd=123456 host=localhost db=ftpdb table=ftpusers usercolumn=name passwdcolumn=password crypt=2
修改stone属性
mkdir -p /etc/vsftpd/vsftpd_user_conf;mkdir /home/stone;chown virtual.virtual /home/stone/;cd /etc/vsftpd/vsftpd_user_conf;vi stone
local_root=/home/stone
anon_other_write_enable=YES
anon_upload_enable=YES
write_enable=YES
anon_mkdir_write_enable=YES
anon_umask=022
download_enable=YES
systemctl restart vsftpd
Windows命令行输入
ftp 172.30.11.1
stone
stone
mkdir upload
cd upload
put stone.txt