DNS服务器–域间邮件收发

文章目录

    • DNS服务器--域间邮件收发
  • 实验环境
  • 对A主机进行配置
    • 一、创建两台DNS服务器
      • (b)修改named.baidu.com文件
      • (c)修改named.qq.com文件
      • (d)启动服务:
    • 二、添加baidu域
      • 1、修改dovecot服务
      • 2、修改10-mail.conf 配置文件
      • 3、配置sasl服务
    • 三、启动网卡并检查
      • 网络配置(添加IP并启动)
    • 四、查看服务器
    • 五、启动服务
    • 六、关闭防火墙
    • 七、修改权限
    • 测试
  • 对B主机进行配置
    • 一、进入B主机, 将A主机的 main.cf 文件拷贝到 B 主机/etc/postifix/ 目录下
    • 二、对拷贝过来的main.cf文件进行修改
      • 1、修改dovecot服务
      • 2、修改10-mail.conf 配置文件
      • 3、配置sasl服务
    • 三、配置并启动网卡
    • 四、启动服务
    • 五、关闭防火墙
    • 六、修改权限
    • 测试
  • 综合测试
    • 一、one用户发送给king用户
    • 二、king用户发送给one用户

实验环境

两台Redhat虚拟机

系统版本

[root@wang named]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.2 (Ootpa)

需要安装的包

dnf install cyrus-sasl dovecot *sasl* -y
dnf install postfix dovecot -y
dnf install postfix mailx -y
dnf install *sasl* -y

对A主机进行配置

一、创建两台DNS服务器

(a)添加配置

vim /etc/named.conf
options {listen-on port 53 { 192.168.9.129; };directory       "/var/named";
};zone "baidu.com" IN {type master;file "named.baidu.com";
};zone "qq.com" IN {type master;file "named.qq.com";
};

(b)修改named.baidu.com文件

vim /var/named/named.baidu.com
$TTL    1D
@       IN      SOA     @       admin.baidu.com. (0531015 )IN              NS              ns.baidu.com.IN              MX              10              mail.baidu.com.
ns              IN              A               192.168.9.129
mail            IN              A               192.168.9.129

©修改named.qq.com文件

vim /var/named/named.qq.com
$TTL    1D
@       IN      SOA     @       admin.qq.com. (0531015 )IN              NS              ns.qq.com.IN              MX              10              mail.qq.com.
ns              IN              A               192.168.9.129
mail            IN              A               192.168.9.135

PS:小技巧

:%s/baidu/qq/g

作用:在vim编辑器种 将baidu 替换成 qq

(d)启动服务:

systemctl restart named

二、添加baidu域

1、修改dovecot服务

进入文件:

vim /etc/dovecot/dovecot.conf

修改内容:

#将第24行修改为下行所示
protocols = imap pop3 lmtp#将下行写入第49行
login_trusted_networks = 192.168.9.0/24

2、修改10-mail.conf 配置文件

进入文件:

vim /etc/dovecot/conf.d/10-mail.conf

修改内容:

#在第30写入下列内容,或者将第25行修改成下行所示
mail_location = mbox:~/mail:INBOX=/var/mail/%u

修改权限:

chmod 0600 /var/mail/*

3、配置sasl服务

vim /etc/postfix/main.cf

需要修改的内容:

————————————————————————————————————————————————第一处——————————————————————————————————————————————————89 # The myhostname parameter specifies the internet hostname of this90 # mail system. The default is to use the fully-qualified domain name91 # from gethostname(). $myhostname is used as a default value for many92 # other configuration parameters.93 94 myhostname = mail.baidu.com————————————————————————————————————————————————第二处——————————————————————————————————————————————————97 # The mydomain parameter specifies the local internet domain name.98 # The default is to use $myhostname minus the first component.99 # $mydomain is used as a default value for many other configuration
100 # parameters.
101
102 mydomain = baidu.com————————————————————————————————————————————————第三处——————————————————————————————————————————————————
113 # For the sake of consistency between sender and recipient addresses,
114 # myorigin also specifies the default domain name that is appended
115 # to recipient addresses that have no @domain part.
116 #
117 #myorigin = $myhostname
118 myorigin = $mydomain————————————————————————————————————————————————第四处——————————————————————————————————————————————————
132 inet_interfaces = all
133 #inet_interfaces = $myhostname
134 #inet_interfaces = $myhostname, localhost
135 #inet_interfaces = localhost————————————————————————————————————————————————第五处——————————————————————————————————————————————————
137 # Enable IPv4, and IPv6 if supported
138 inet_protocols = all————————————————————————————————————————————————第六处——————————————————————————————————————————————————
183 #mydestination = $myhostname, localhost.$mydomain, localhost
184 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
185 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
186 #       mail.$mydomain, www.$mydomain, ftp.$mydomain————————————————————————————————————————————————第七处——————————————————————————————————————————————————# You can also specify the absolute pathname of a pattern file instead
281 # of listing the patterns here. Specify type:table for table-based lookups
282 # (the value on the table right-hand side is not used).
283 #
284 mynetworks = 192.168.9.0/24, 127.0.0.0/8
285 #mynetworks = $config_directory/mynetworks
286 #mynetworks = hash:/etc/postfix/network_table————————————————————————————————————————————————第八处——————————————————————————————————————————————————
12 # NOTE: Postfix will not automatically forward mail for domains that
313 # list this system as their primary or backup MX host. See the
314 # permit_mx_backup restriction description in postconf(5).
315 #
316 relay_domains = $mydestination————————————————————————————————————————————————第九处——————————————————————————————————————————————————
#最后面
737 smtp_tls_security_level = may
738 meta_directory = /etc/postfix
739 shlib_directory = /usr/lib64/postfix
740
742 broken_sasl_auth_clients = yes
743 smtpd_sasl_auth_enable = yes
744 smtpd_sasl_security_options = noanonymous
745 smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

三、启动网卡并检查

网络配置(添加IP并启动)

nmcli connection modify ens160 ipv4.dns 192.168.9.129
nmcli connection modify ens160 ipv4.method manual
nmcli connection up ens160

注意:nmcli connection modify ens160 ipv4.method manual 该命令作用是修改为手动配置

四、查看服务器

nmcli device show | grep DNS

五、启动服务

systemctl restart postfix
systemctl restart dovecot
systemctl restart saslauthd

六、关闭防火墙

systemctl stop firewalld

七、修改权限

setenforce 0

测试

dig -t mail.qq.com
dig -t mail.baidu.com

对B主机进行配置

一、进入B主机, 将A主机的 main.cf 文件拷贝到 B 主机/etc/postifix/ 目录下

scp root@192.168.9.129:/etc/postfix/main.cf /etc/postifix/

注意:

192.168.9.129是baidu域主机的IP地址

192.168.9.135是qq 域的主机的IP地址

二、对拷贝过来的main.cf文件进行修改

1、修改dovecot服务

进入文件:

vim /etc/dovecot/dovecot.conf

修改内容:

#将第24行修改为下行所示
protocols = imap pop3 lmtp#将下行写入第49行
login_trusted_networks = 192.168.9.0/24

2、修改10-mail.conf 配置文件

进入文件:

vim /etc/dovecot/conf.d/10-mail.conf

修改内容:

#在第30写入下列内容,或者将第25行修改成下行所示
mail_location = mbox:~/mail:INBOX=/var/mail/%u

修改权限:

chmod 0600 /var/mail/*

3、配置sasl服务

vim /etc/postfix/main.cf
————————————————————————————————————————————————第一处——————————————————————————————————————————————————
89 # The myhostname parameter specifies the internet hostname of this90 # mail system. The default is to use the fully-qualified domain name91 # from gethostname(). $myhostname is used as a default value for many92 # other configuration parameters.93 94 myhostname = mail.qq.com————————————————————————————————————————————————第二处—————————————————————————————————————————————————97 # The mydomain parameter specifies the local internet domain name.98 # The default is to use $myhostname minus the first component.99 # $mydomain is used as a default value for many other configuration
100 # parameters.
101
102 mydomain = qq.com————————————————————————————————————————————————第三处——————————————————————————————————————————————————
113 # For the sake of consistency between sender and recipient addresses,
114 # myorigin also specifies the default domain name that is appended
115 # to recipient addresses that have no @domain part.
116 #
117 #myorigin = $myhostname
118 myorigin = $mydomain————————————————————————————————————————————————第四处——————————————————————————————————————————————————
132 inet_interfaces = all
133 #inet_interfaces = $myhostname
134 #inet_interfaces = $myhostname, localhost
135 #inet_interfaces = localhost————————————————————————————————————————————————第五处——————————————————————————————————————————————————
137 # Enable IPv4, and IPv6 if supported
138 inet_protocols = all————————————————————————————————————————————————第六处——————————————————————————————————————————————————
183 #mydestination = $myhostname, localhost.$mydomain, localhost
184 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
185 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
186 #       mail.$mydomain, www.$mydomain, ftp.$mydomain————————————————————————————————————————————————第七处——————————————————————————————————————————————————
280# You can also specify the absolute pathname of a pattern file instead
281 # of listing the patterns here. Specify type:table for table-based lookups
282 # (the value on the table right-hand side is not used).
283 #
284 mynetworks = 192.168.9.0/24, 127.0.0.0/8
285 #mynetworks = $config_directory/mynetworks
286 #mynetworks = hash:/etc/postfix/network_table————————————————————————————————————————————————第八处——————————————————————————————————————————————————
12 # NOTE: Postfix will not automatically forward mail for domains that
313 # list this system as their primary or backup MX host. See the
314 # permit_mx_backup restriction description in postconf(5).
315 #
316 relay_domains = $mydestination————————————————————————————————————————————————第九处——————————————————————————————————————————————————
#最后面
737 smtp_tls_security_level = may
738 meta_directory = /etc/postfix
739 shlib_directory = /usr/lib64/postfix
740
742 broken_sasl_auth_clients = yes
743 smtpd_sasl_auth_enable = yes
744 smtpd_sasl_security_options = noanonymous
745 smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

三、配置并启动网卡

nmcli connection modify ens160 ipv4.addresses 192.168.9.135/24
nmcli connection modify ens160 ipv4.method manual
nmcli connection modify ens160 connection.autoconnect yes
nmcli connection modify ens160 ipv4.dns 192.168.9.129
nmcli connection up ens160

四、启动服务

systemctl restart postfix
systemctl restart dovecot
systemctl restart saslauthd

五、关闭防火墙

systemctl stop firewalld

六、修改权限

setenforce 0

测试

dig -t A mail.qq.com
dig -t A mail.baidu.com

综合测试

使用foxmail添加不同域之间的用户 相互发送信息

注意:

king是baidu域的用户
one 是qq域的用户

一、one用户发送给king用户

二、king用户发送给one用户

邮件服务器4—域间收发相关推荐

  1. TurboMail独家提供邮件服务器与Outlook间的地址簿同步插件

    2019独角兽企业重金招聘Python工程师标准>>> TurboMail邮件服务器有较大的客户群使用Outlook客户端来收发邮件,为了满足Outlook客户端用户群的便利要求,T ...

  2. 怎样在手机自带的邮件服务器,如何在手机上收发学校邮箱信件

    学校邮箱系统支持手机app收发邮件.设置步骤如下:(手机除了界面略有区别外,操作基本类似) 1.进入手机--设置--账户--邮件 2.选择账户设置 3.选择添加账户 4.选择"其他" ...

  3. RHCE(十三)用postfix搭建邮件服务器

    搭建邮件服务器 postfix 邮件系统的组成 邮件服务工作流程 三种协议 SMTP POP3 IMAP POP3 和 IMAP 区别 常用端口 mail命令 邮件群发 搭建框架 Linux系统上搭建 ...

  4. 网络安全学习笔记——第十五天 域内NAT、域间NAT技术及配置实验

    双向NAT技术 双向NAT两种应用场景: ○ NAT Server+源NAT(又称作域间双向NAT) 为了简化配置服务器至公网的路由,可在NAT Server基础上,增加源NAT配置.好处就是,服务器 ...

  5. 邮件发送--局域网中配置James邮件服务器(二)

    邮件服务器软件有很多种,这里为大家介绍James邮件服务器的搭建与使用.James是属于Apache的一个开源项目,是Apache组织构建的一个可移植的.安全的.100%纯Java实现的企业级邮件服务 ...

  6. 邮件服务器收发邮件时常发生的问题

    绝大部分发信失败都是因为DNS设置不当或防火墙设置错误引起的.您需确认: 1) 是否设置有DNS服务器地址: 2) 所设置的DNS服务器地址是否是有效的,此DNS服务器是否正常工作,可否进行正常DNS ...

  7. linux mysql 邮件_linux 下 搭建邮件邮件服务器(Postfix+Dovecot)(二)-基于mysql的虚拟账户登陆收发邮件...

    linux 下 搭建邮件邮件服务器(Postfix+Dovecot)(二)-基于mysql的虚拟账户登陆收发邮件 使用虚拟用户收发邮件安装 九.安装Courier authentication lib ...

  8. linux 下 搭建邮件邮件服务器(Postfix+Dovecot)(二)-基于mysql的虚拟账户登陆收发邮件...

    linux 下 搭建邮件邮件服务器(Postfix+Dovecot)(二)-基于mysql的虚拟账户登陆收发邮件 使用虚拟用户收发邮件安装 九.安装Courier authentication lib ...

  9. 2.架设邮件服务器-windows 2003 POP3服务,SMTP服务收发邮件

    1.默认安装的系统是没有安装POP3组件,SMTP组件,搞个盘过来,或从网上下载一个i386(下载地址:http://down.spdns.com/i386.rar ). (1)从"控制面板 ...

最新文章

  1. java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id null
  2. spring系列-注解驱动原理及源码-bean生命周期
  3. ExtJs实践(3)——xtype名称与控件对应
  4. OPEN(SAP) UI5 学习入门系列之四:更好的入门系列-官方Walkthrough
  5. 网校网络工程师视频下载
  6. power bi 参数_参数化Power BI报表入门
  7. 啦啦啦-我又来了!!!
  8. golang连接mysql操作示例增删改查
  9. Linux的EXPORT_SYMBOL和EXPORT_SYMBOL_GPL的使用和区别
  10. astrolog php,如何在苹果MAC上使用Astrolog32 zet9等占星软件
  11. 王者荣耀服务器不稳定总是跳频,vivo iQOO Pro 5G手机打玩王者荣耀网络不稳定出现断流...
  12. Win10使用Windows照片查看器(Windows Photo Viewer)来打开图片
  13. 工作缺点和不足及措施_个人工作问题不足20条以及改进措施
  14. 登录验证,如果输入错误次数超过3次,则锁定该账户
  15. 手持式水质监测仪在污水处理中的应用
  16. 代码实证:风险平价及其改进思路——主成分风险平价
  17. 分享117个HTML个性简实模板,总有一款适合您
  18. Java毕设项目线上教学平台(java+VUE+Mybatis+Maven+Mysql)
  19. Java基础题36:(多选题)下列有关于变量的命名正确的是 A.可以由字母、数字、下划线、”$”组成; 头
  20. 算法-大作业-圆排列问题

热门文章

  1. 阴阳师服务器维护 2月11,阴阳师2月11日维护延迟到几点 什么时候开服
  2. 一把王者的时间,我就学会了 Nginx
  3. VP9如何给Twitch的电竞直播带来价值?
  4. php跳出volist,在thinkphp5框架下,用了{volist},然后退出循环{/volist},但进行另一个循环输出时却在下一行开始了。...
  5. 一年中最后一个月的最后一天说说_月底月末最后一天说说心情语句 一个月又过了感慨感悟短语...
  6. Python获取英雄联盟皮肤原画:新手玩家们都懵了!
  7. 分布式事务(二)、刚性事务之 2PC、3PC
  8. Java List集合反转元素
  9. 《图解深度学习》学习笔记(二)
  10. 越穷越尖酸#65380;越丑越刻薄