######邮件部分######
6.限制用户发送
1.过滤sender
[[email protected] ~]# postconf -d | grep sender
2.hash加密
[[email protected] ~]# postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"
[[email protected] ~]# vim /etc/postfix/sender ##添加拒绝的用户
1 [email protected] REJECT ##拒绝[email protected] 发送邮件(但可以接收)
[[email protected] ~]# postmap /etc/postfix/sender ##加密生成.db文件
[[email protected] ~]# cd /etc/postfix/
[[email protected] postfix]# ls
access header_checks relocated virtual
access.db main.cf sender
canonical master.cf sender.db
generic moreuser transport
[[email protected] postfix]# systemctl restart postfix.service
测试:
[[email protected] Desktop]$ telnet 172.25.254.113 25
Trying 172.25.254.113...
Connected to 172.25.254.113.
Escape character is ‘^]‘.
220 westos-mail.westos.com ESMTP Postfix
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <unknown[172.25.254.13]>: Client host rejected: Access denied
Connection closed by foreign host.
[[email protected] Desktop]$
7.限制用户接收
[[email protected] postfix]# postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip"
[[email protected] postfix]# vim /etc/postfix/recip
[email protected] REJECT ##限制此用户接收
~
[[email protected] postfix]# postmap /etc/postfix/recip
[[email protected] postfix]# systemctl restart postfix.service
测试:
1)westos作为发送端
[[email protected] Desktop]$ telnet 172.25.254.113 25
Trying 172.25.254.113...
Connected to 172.25.254.113.
Escape character is ‘^]‘.
220 westos-mail.westos.com ESMTP Postfix
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
haha
.
250 2.0.0 Ok: queued as F3FAA246207
quit##发送成功
221 2.0.0 Bye
Connection closed by foreign host.
2)westos作为接收端
[[email protected] Desktop]$ telnet 172.25.254.113 25
Trying 172.25.254.113...
Connected to 172.25.254.113.
Escape character is ‘^]‘.
220 westos-mail.westos.com ESMTP Postfix
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <unknown[172.25.254.13]>: Client host rejected: Access denied ##接收被拒
8.出站地址伪装
[[email protected] postfix]# postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"
[[email protected] postfix]# vim /etc/postfix/main.cf
[[email protected] postfix]# vim /etc/postfix/generic
241 [email protected] [email protected]
[[email protected] postfix]# postmap /etc/postfix/generic
[[email protected] postfix]# systemctl restart postfix.service
测试:
[[email protected] postfix]# su - westos
[[email protected] postfix]$ mail [email protected]
Subject: wq
wqq
.
EOT
[[email protected] ~]# mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 1 messages 1 new 3
>N 1 [email protected] Sat May 20 22:30 21/718 "wq"
& 1
Message 1:
From [email protected] Sat May 20 22:30:30 2017
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Date: Sat, 20 May 2017 22:30:29 -0400
To: [email protected]
Subject: wq
User-Agent: Heirloom mailx 12.5 7/5/10
Content-Type: text/plain; charset=us-ascii
From: [email protected]
Status: R
wqq
& q
Held 1 messages in /var/spool/mail/root
You have mail in /var/spool/mail/root
9.入站地址转换
dns mx 记录解析先做好
[[email protected] postfix]$ vim /etc/named.rfc1912.zones
[[email protected] named]# cp qq.com.zone haha.com.zone -p
[[email protected] named]# vim haha.com.zone
[[email protected] named]# systemctl restart named
[[email protected] named]# postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
[[email protected] named]# vim /etc/postfix/virtual
[email protected] [email protected]
虚拟名字 真实用户
[[email protected] postfix]# postmap /etc/postfix/virtual ##生成加密的.db文件
[[email protected] postfix]# systemctl restart postfix.service
测试:
[[email protected] postfix]# mail [email protected]
Subject: qqq
qqq
.
EOT
[[email protected] named]# mail -u westos
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/mail/westos": 4 messages 1 new
1 root Sat May 20 23:36 20/574 "adf"
2 root Sun May 21 00:49 19/567 "wq"
3 root Sun May 21 01:18 19/568 "hao"
>N 4 root Sun May 21 01:24 21/710 "qqq"
& 4
Message 4:
From [email protected] Sun May 21 01:24:30 2017
Return-Path: <[email protected]>
X-Original-To: [email protected] ##发送方显示的用户
Delivered-To: [email protected] ##实际发送的用户
Date: Sun, 21 May 2017 01:24:29 -0400
To: [email protected]
Subject: qqq
User-Agent: Heirloom mailx 12.5 7/5/10
Content-Type: text/plain; charset=us-ascii
From: [email protected] (root)
Status: R
qqq
& q
Held 4 messages in /var/mail/westos