![]() |
Postfix & PostFWD Integration - CentOS 6.8
Greetings all, this may be a long post, but bear with me. Most of the info is just code and command line snippets.
Essentially, I needed a way to be able to agressively rate limit the number of mails that were being sent TO a specific domain (the whole domain), any mail that exceeded the rate limit needs to be rejected of dropped. Not delayed of deferred. The main issue? I cannot use Exim or any other friendly MTA. I MUST use postfix, so here we are, with Postfix and PostFWD, and a couple of issues. Code:
Some versions..Code:
[root@monitoringtest ~]# /usr/local/postfwd/sbin/postfwd -f /etc/postfix/postfwd.cf -CA quick check to ensure Postfix and PostFWD are up and listening (they are): Code:
[root@monitoringtest ~]# netstat -anpl | grep ':10040\|:25'Code:
[root@monitoringtest ~]# nc 127.0.0.1 10040 </usr/local/postfwd/tools/request.sampleCode:
Oct 19 17:15:47 monitoringtest postfwd[25933]: [RULES] rule=0, id=davelimit001, client=root@monitoringtest.co.uk[168.100.1.7], Code:
[root@monitoringtest ~]# tail -n 3 /etc/postfix/main.cfI then use telnet locally to connect to Postfix and send emails to admin[at]dave-byrne.co.uk. Like so: Code:
[root@dedweb ~]# telnet <test-server-IP-here> smtpAnd this is where I'm stuck. 3 days in and I'm none the wiser. Has anyone ever used PostFWD (Postfix Firewall Daemon) before successfully, with any type of rule set, regardless of rate limiting. I'm open to many suggestions, however I cannot change from postfix, I cannot change OS, and I cannot hand off to an external intermediate mail relay due to security concerns and workflow issues with what's actually being sent. Thanks all, Dave. |
Immediately after asking this question, I realised that postfix recipient restrictions are executed in the order they appear in main.cf. So my
Code:
[root@monitoringtest ~]# tail -n 3 /etc/postfix/main.cfI resolved my issue by placing the check_policy_service at the top of my smtp recipient restrictions. If PostFWD passes a mail, it replies with 'DUNNO' or rather 'DUNNO/OK', this passes, but continues to run further smtp restrictions. With this in place, PostFWD was free to pass the mail that didn't trigger the rate limit, but once it did trigger the rate limit, it replied with a 421 rejection. Exactly what I wanted. So keep in mind, the order in which you restrict, and what you are actually restricting, matters quite a lot. Please note that this is a private internal mail server that serves one very specific purpose. Do not use this code for a production or shared mail server |
| All times are GMT -5. The time now is 04:57 PM. |