CentOS 7.9 邮箱部署——Postfix+Dovecot详细

Postfix+Dovecot

资源列表

操作系统配置主机名IP所需软件
CentOS 7.92C4Gns.bdqn.com192.168.93.101bind
postfix
dovecot
ssl证书
Windows 102C4GclientIP:192.168.93.100
网关:192.168.93.101
FoxmailSetup_7.2.23.121

基础环境

  • 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
  • 关闭内核安全机制
setenforce 0
sed -i "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
  • 修改主机名
hostnamectl set-hostname ns.bdqn.com

一、部署DNS

  • 邮件服务器做下面操作 (ns.bdqn.com)
[root@ns ~]# yum -y install bind*
# 备份主配置文件
[root@ns ~]# cp /etc/named.conf /tmp/named.conf.bak

[root@ns ~]# vim /etc/named.conf
# 原有的基础上修改
options {
        listen-on port 53 { 192.168.93.101; };
		allow-query     { any; };
        
# 末尾添加即可
zone "bdqn.com" IN {
        type master;
        file "bdqn.com.zone";
        allow-transfer {192.168.93.100;};
};


# 拷贝一个正向解析区域文件进行修改
[root@ns ~]# cp -p /var/named/named.localhost /var/named/bdqn.com.zone
[root@ns ~]# vim /var/named/bdqn.com.zone 
$TTL 1D
@       IN SOA  bdqn.com. admin.bdqn.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       NS      ns.bdqn.com.
        MX      10      mail.bdqn.com.
ns      A       192.168.93.101
mail    A       192.168.93.101
*       A       192.168.93.101


# 重新设置权限
[root@ns ~]# chown named:named /etc/named.conf
[root@ns ~]# chown named:named /var/named/bdqn.com.zone 



[root@ns ~]# systemctl start named
[root@ns ~]# systemctl enable named

  • Windows 10 修改DNS
    在这里插入图片描述

  • 测试DNS

# Winsows 10 打开CMD进行ping测试
ping mail.bdqn.com
ping ns.bdqn.com
ping web.bdqn.com

二、部署postfix和dovecot

  • ns.bdqn.com节点操作

2.1、配置postfix

  • postfix:提供发邮件功能
[root@ns ~]# yum -y install postfix		# 默认已经安装


以下操作均默认存在,只需要在原有的配置上进行修改即可
[root@ns ~]# vim /etc/postfix/main.cf 
myhostname = ns.bdqn.com   # 填写服务器主机名
mydomain = bdqn.com		# 设置服务器域名
inet_interfaces = 192.168.93.101	# 修改监听地址,也可以写成all
mydestination = $mydomain,$myhostname	# 定义可接受的主机或域名列表
home_mailbox = Maildir/		# 邮箱保存路径
[root@ns ~]# systemctl restart postfix.service 

# 监听postfix端口,25
[root@ns ~]# netstat -anpt | grep 25
tcp        0      0 192.168.93.101:25       0.0.0.0:*               LISTEN      14995/master   

2.2、配置dovecot

  • dovecot:提供发邮件功能
[root@ns ~]# yum -y install dovecot*   # 安装发邮件服务

先进行全局搜索配置项,有的话就修改,没有就添加
[root@ns ~]# vim /etc/dovecot/dovecot.conf 
!include conf.d/10-auth.conf
ssl=no	
disable_plaintext_auth = no
mail_location=maildir:~/Maildir

[root@ns ~]# systemctl start dovecot
[root@ns ~]# systemctl enable dovecot

# 监听dovecot端口、110
[root@ns ~]# netstat -anpt | grep 110
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      15233/dovecot       
tcp6       0      0 :::110                  :::*                    LISTEN      15233/dovecot    

2.3、创建邮件用户

[root@ns ~]# groupadd mailusers
[root@ns ~]# useradd -g mailusers -s /sbin/nologin test01
[root@ns ~]# useradd -g mailusers -s /sbin/nologin test02
[root@ns ~]# echo "123" | passwd --stdin test01
[root@ns ~]# echo "123" | passwd --stdin test02
[root@ns ~]# chmod 600 /var/mail/*


三、发送邮件测试

3.1、windows安装poxmail

  • 下面是下载软件地址
https://dldir1.qq.com/foxmail/windows/FoxmailSetup_7.2.23.121.exe

3.2、登录邮箱

  • 登录test01用户账号
    在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

  • 登录test02邮箱账号
    在这里插入图片描述

在这里插入图片描述

3.3、发送接收邮件

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

四、搭建SSL认证加密

  • 安装搭建SSL认证加密,防止有人窃取文件
[root@ns ~]# yum -y install openssl		# 默认已经安装

4.1、生成私钥

# 生成私钥
[root@ns ~]# cd /etc/pki/tls/certs/
[root@ns certs]# make server.key
umask 77 ; \
/usr/bin/openssl genrsa -aes128 2048 > server.key
Generating RSA private key, 2048 bit long modulus
.....................................+++
.........................................................................................+++
e is 65537 (0x10001)
Enter pass phrase:		# 密码123456
Verifying - Enter pass phrase:		# 确认密码

[root@ns certs]# openssl rsa -in server.key -out server.key
Enter pass phrase for server.key:		# 输入刚刚的密码123456
writing RSA key



4.2、生成公钥

# 生成公钥
[root@ns certs]# make server.csr
umask 77 ; \
/usr/bin/openssl req -utf8 -new -key server.key -out server.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN	#中国
State or Province Name (full name) []:HeNan		#河南
Locality Name (eg, city) [Default City]:ZhengZhou	#郑州
Organization Name (eg, company) [Default Company Ltd]:kgc #单位
Organizational Unit Name (eg, section) []:jisuanji	#组织单位
Common Name (eg, your name or your server's hostname) []:bdqn.com
Email Address []:	#回车

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:	#回车
An optional company name []:	#回车

4.3、生成自签证书

[root@ns certs]# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
Signature ok
subject=/C=CN/ST=HeNan/L=ZhengZhou/O=kgc/OU=jisuanji/CN=bdqn.com
Getting Private key

4.4、更改证书权限

[root@ns certs]# chmod 400 server.*
[root@ns certs]# ls server.*
server.crt  server.csr  server.key

4.5、配置发件SSL

[root@ns certs]# vim /etc/postfix/main.cf 
# 末尾添加即可
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/pki/tls/certs/server.crt
smtpd_tls_key_file = /etc/pki/tls/certs/server.key

[root@ns certs]# vim /etc/postfix/master.cf 
# 26、28行取消注释
smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes

# 监听端口、465
[root@ns certs]# systemctl restart postfix.service 
[root@ns certs]# netstat -anpt | grep 465
tcp        0      0 192.168.93.101:465      0.0.0.0:*               LISTEN      15621/master   

4.6、配置收件SSL

[root@ns certs]# vim /etc/dovecot/dovecot.conf 
# 将下面一行配置端更改为*
!include conf.d/*.conf
# 删除下面两行配置项
ssl=no
disable_plaintext_auth = no

[root@ns certs]# vim /etc/dovecot/conf.d/10-ssl.conf 
ssl = yes	# 更改为yes
# 修改下面两行配置项
ssl_cert = </etc/pki/tls/certs/server.crt
ssl_key = </etc/pki/tls/certs/server.key
[root@ns certs]# systemctl restart dovecot

# 监听端口、995
[root@ns certs]# netstat -anpt | grep 995
tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN      15752/dovecot       
tcp6       0      0 :::995                  :::*                    LISTEN      15752/dovecot    

五、验证SSL

  • test01、test02都开启SSL端口分别为995、465
    在这里插入图片描述

  • 进行发送跟接收文件步骤和第三步骤一样,重复一遍即可

  • 9
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CentOS+Postfix+Dovecot+Postfixadmin+Roundcube邮件服务器的搭建步骤如下: 1. 安装 CentOS 操作系统,并更新至最新版。 2. 安装 Postfix 邮件服务器,并进行基本配置。 3. 安装 Dovecot IMAP/POP3 服务器,并进行基本配置。 4. 安装 Postfixadmin 邮箱管理系统,并进行基本配置。 5. 安装 Roundcube Webmail 邮件客户端,并进行基本配置。 具体步骤如下: 1. 安装 CentOS 操作系统,并更新至最新版。 在安装 CentOS 操作系统时,选择最小化安装,并根据实际情况进行分区和网络配置。安装完成后,使用以下命令更新系统: ``` yum update ``` 2. 安装 Postfix 邮件服务器,并进行基本配置。 使用以下命令安装 Postfix: ``` yum install postfix ``` 安装完成后,修改 /etc/postfix/main.cf 文件,使其支持 TLS 和 SASL 认证: ``` smtpd_tls_cert_file = /etc/pki/tls/certs/server.crt smtpd_tls_key_file = /etc/pki/tls/private/server.key smtpd_tls_security_level = may smtp_tls_security_level = may smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination ``` 然后重启 Postfix 服务: ``` systemctl restart postfix ``` 3. 安装 Dovecot IMAP/POP3 服务器,并进行基本配置。 使用以下命令安装 Dovecot: ``` yum install dovecot ``` 安装完成后,修改 /etc/dovecot/dovecot.conf 文件,使其支持 TLS 和 SASL 认证: ``` ssl_cert = </etc/pki/tls/certs/server.crt ssl_key = </etc/pki/tls/private/server.key auth_mechanisms = plain login ``` 然后重启 Dovecot 服务: ``` systemctl restart dovecot ``` 4. 安装 Postfixadmin 邮箱管理系统,并进行基本配置。 使用以下命令安装 Postfixadmin: ``` yum install postfixadmin ``` 安装完成后,修改 /etc/httpd/conf.d/postfixadmin.conf 文件,使其支持 SSL: ``` SSLEngine on SSLCertificateFile /etc/pki/tls/certs/server.crt SSLCertificateKeyFile /etc/pki/tls/private/server.key ``` 然后重启 Apache 服务: ``` systemctl restart httpd ``` 访问 https://your-domain.com/postfixadmin,使用管理员账号登录,创建邮箱账号和域名等相关配置。 5. 安装 Roundcube Webmail 邮件客户端,并进行基本配置。 使用以下命令安装 Roundcube: ``` yum install roundcubemail ``` 安装完成后,修改 /etc/httpd/conf.d/roundcubemail.conf 文件,使其支持 SSL: ``` SSLEngine on SSLCertificateFile /etc/pki/tls/certs/server.crt SSLCertificateKeyFile /etc/pki/tls/private/server.key ``` 然后重启 Apache 服务: ``` systemctl restart httpd ``` 访问 https://your-domain.com/roundcubemail,使用邮箱账号登录,即可使用 Roundcube 邮件客户端。 以上就是 CentOS+Postfix+Dovecot+Postfixadmin+Roundcube邮件服务器的搭建步骤,如有问题可以参考相关文档或者咨询技术人员。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值