How to block/permit all email sent from a particular IP/range in Postfix
Environment
- Red Hat Enterprise Linux
- Postfix
Issue
- How to permit only some hosts or subnets to send mail
Resolution
Steps below would allow only subnet 10.0.0.0/24 and host 10.0.1.15 to send mail through the server.
-
Make sure
/etc/postfix/accessfile exist and has following lines:10.0.1.15 OK 10.0.0.0/24 OK -
Run postmap against
/etc/postfix/accessfile# postmap /etc/postfix/access -
Setup the
smtpd_client_restrictionsin the/etc/postfix/main.cfto allow only mynetworks and IP addresses from the/etc/postfix/accesssmtpd_client_restrictions = permit_mynetworks, check_client_access cidr:/etc/postfix/access, reject -
Restart postfix service
# service postfix restart
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments