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/access
file exist and has following lines:10.0.1.15 OK 10.0.0.0/24 OK
-
Run postmap against
/etc/postfix/access
file# postmap /etc/postfix/access
-
Setup the
smtpd_client_restrictions
in the/etc/postfix/main.cf
to allow only mynetworks and IP addresses from the/etc/postfix/access
smtpd_client_restrictions = permit_mynetworks, check_client_access hash:/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