限制用户发送
配置
[root@westos-mail ~]# postconf -e “smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender”
[root@westos-mail ~]# vim /etc/postfix/sender
student@westos.com REJECT ##限制student@westos.com用户发送
[root@westos-mail ~]# postmap /etc/postfix/sender ##加密
[root@westos-mail ~]# systemctl restart postfix.service
测试
[kiosk@foundation19 Desktop]$ telnet 172.25.254.119 25
Trying 172.25.254.119…
Connected to 172.25.254.119.
Escape character is ‘^]’.
220 westos-mail.westos.com ESMTP Postfix
mail from: root@westos.com ##用root@westos.com发送
250 2.1.0 Ok
rcpt to: root@qq.com
250 2.1.5 Ok
data
354 End data with .
22222222222222222
.
250 2.0.0 Ok: queued as 07C1C246207 ##发送成功
mail from: student@westos.com ##用student@westos.com发送
250 2.1.0 Ok
rcpt to: root@qq.com
554 5.7.1 student@westos.com: Sender address rejected: Access denied ##受限
限制用户接收
配置
[root@westos-mail ~]# postconf -e “smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip”
[root@westos-mail ~]# vim /etc/postfix/recip
student@westos.com REJECT ##限制student@westos.com用户接收
[root@westos-mail ~]# postmap /etc/postfix/recip ##加密
[root@westos-mail ~]# systemctl restart postfix.service
测试
[kiosk@foundation19 Desktop]$ telnet 172.25.254.119 25
Trying 172.25.254.119…
Connected to 172.25.254.119.
Escape character is ‘^]’.
220 westos-mail.westos.com ESMTP Postfix
mail from: student@westos.com ##用student@westos.com发送
250 2.1.0 Ok
rcpt to: root@qq.com
250 2.1.5 Ok
data
354 End data with .
dassssssssssssssssssssssss
.
250 2.0.0 Ok: queued as 79120EAC28 ##发送成功
mail from: root@westos.com
250 2.1.0 Ok
rcpt to: student@westos.com ##用student@westos.com接受
554 5.7.1 student@westos.com: Recipient address rejected: Access denied ##受限
出站地址伪装
配置
[root@westos-mail ~]# postconf -e “smtp_generic_maps = hash:/etc/postfix/generic”
[root@westos-mail ~]# vim /etc/postfix/generic
真实名 伪装名
student@westos.com hello@sb.com
[root@westos-mail ~]# postmap /etc/postfix/generic
[root@westos-mail ~]# systemctl restart postfix.service
测试
[root@westos-mail ~]# su - student
[student@westos-mail ~]$ mail root@qq.com
入站地址转换
配置
配置dns 记录解析
[root@westos-mail ~]# vim /etc/named.rfc1912.zones
zone “sb.com” IN {
type master;
file “sb.com.zone”;
allow-update { none; };
};
[root@westos-mail ~]# cp -p /var/named/westos.com.zone /var/named/sb.com.zone
[root@westos-mail ~]# vim /var/named/sb.com.zone
$TTL 1D
@ IN SOA sb.com. root.sb.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.sb.com.
dns A 172.25.254.119
sb.com. MX 1 172.25.254.119.
[root@westos-mail ~]# systemctl restart named
配置别名
[root@westos-mail ~]# postconf -e “virtual_alias_maps = hash:/etc/postfix/virtual”
[root@westos-mail ~]# vim /etc/postfix/virtual
虚拟名 真实名
hello@sb.com student@westos.com
[root@westos-mail ~]# postmap /etc/postfix/virtual
[root@westos-mail ~]# systemctl restart postfix.service
测试
[root@qq-mail ~]# mail hello@sb.com