postfix服务 dns服务练习
使用rose@qq.com给jack@163.com用户发一封邮件,内容为you jump,i jump.
128这台主机
1.装包postfix 关防火墙和selinux
yum install -y postfix
systemctl stop firewalld
setenforce 0
2.修改配置文件 vim /etc/postfix/main.cf
更改七条参数
注释掉这条
3.重启服务 systemctl restart postfix
4.添加用户并设置密码
[root@128 ~]# useradd rose
[root@128 ~]# passwd rose
5.安装mailx dovecot cyrus-sasl
[root@128 ~]# yum install mailx -y
[root@128 ~]# yum install dovecot -y
[root@128 ~]# yum install cyrus-sasl -y
6.编辑配置文件 vim /etc/dovecot/dovecot.conf
设置允许登录的网段
[root@128 ~]# vim /etc/dovecot/conf.d/10-mail.conf
用户邮件所在地
开启SASL认证sasl auth model
编辑main.cf配置文件,
[root@localhost ~]# vi /etc/postfix/main.cf
开启SASL认证
vim /etc/postfix/main.cf
编辑main.cf配置文件,追加如下行:
broken_sasl_auth_clients = yes #启用SASL对客户端进行认证
smtpd_sasl_auth_enable = yes #启用SASL认证
smtpd_sasl_security_options = noanonymous #匿名用户
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
#定义收件人限定 =允许sasl接收限制l认证,允许mynetworks,拒绝unauth目的地
7.重启服务
[root@128 ~]# systemctl restart postfix
[root@128 ~]# systemctl restart dovecot
[root@128 ~]# systemctl restart saslauthd
8.更改权限
[root@128 ~]# cd /var/mail/
[root@128 mail]# ll
总用量 8
-rw-------. 1 1001 mail 0 9月 27 16:57 hh
-rw-------. 1 root mail 2993 10月 17 16:59 root
-rw-rw----. 1 rose mail 0 10月 20 17:03 rose
-rw-------. 1 rpc mail 0 7月 25 08:41 rpc
-rw-------. 1 sd mail 0 7月 25 08:53 sd
-rw-rw----. 1 xiaobai mail 3030 10月 17 17:01 xiaobai
-rw-------. 1 xiaohei mail 0 9月 29 18:34 xiaohei
-rw-------. 1 1002 mail 0 9月 29 18:33 xiaoming
[root@128 mail]# chmod 600 /var/mail/*
10 这台主机:
1.装包
yum install -y postfix
yum install -y dovecot
yum install -y mailx
yum install -y cyrus-sasl
2编辑配置
vim /etc/postfix/main.cf
[root@10 ~]# systemctl stop firewalld
[root@10 ~]# setenforce 0
[root@10 ~]# systemctl restart postfix
[root@10 mail]# vim /etc/dovecot/dovecot.conf
[root@10 mail]# vim /etc/dovecot/conf.d/10-mail.conf
[root@10 mail]# systemctl restart dovecot
[root@10 mail]# systemctl restart saslauthd
3.添加用户
[root@10 ~]# useradd jack
[root@10 ~]# passwd jack
4.更改权限
[root@10 mail]# chmod 600 /var/mail/*
不同域的邮件服务器已经配置完成,要使不同的域名能够互发邮件需要配置dns服务
128这台主机做dns服务器:
1.安装 named 编辑配置
[root@128 mail]# yum install -y bind
[root@128 named]# vim /etc/named.conf
options {
listen-on port 53 { 127.0.0.1; };
directory “/var/named”;
};
zone “qq.com” IN {
type master;
file “named.qq.com”;
};
zone “163.com” IN {
type master;
file “named.163.com”;
};
[root@128 named]# vim /var/named/named.qq.com
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS ns.qq.com.
IN MX 10 mail.qq.com.
ns IN A 192.168.183.128
mail IN A 192.168.183.128
[root@128 named]# vim /var/named/named.163.com
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS ns.163.com.
IN MX 10 mail.163.com.
ns IN A 192.168.183.128
mail IN A 192.168.183.10
3.重启服务
[root@128 named]# systemctl restart named
4.编辑配置文件 vim /etc/resolv.conf
nameserver 192.168.183.128
nameserver 192.168.183.2
5.测试
添加qq域的rose
和163域的jack
创作不易,如果你觉得不错的话,就给我点个赞吧



