1

Topic: policyd

hi!

i'm using a freebsd 8.0 system with iredmail.
I have in: /usr/local/etc those 2 file:

postfix-policyd-sf.conf
policyd_sender_throttle.conf


what i want to do is to add in mysql table (policyd) some blacklists and whitelists and make some throttle restrictions.
they are not enabled my default because i inseted some @domains and ips in blackist and whitelist and nothing happens.

what file should i edit for this features?! postfix-policyd-sf.conf or policyd_sender_throttle.conf ?

regards

2

Re: policyd

postfix-policyd-sf.conf.

3

Re: policyd

ZhangHuangbin wrote:

postfix-policyd-sf.conf.

thanks for your answer!

how about throttling?

i added to policyd.throttle:

INSERT INTO throttle
(_from,_count_max,_quota_max,_time_limit,_mail_size,_date,_priority)
VALUES ('myuser@domain.com',    2, 250000000,60, 10240000,UNIX_TIMESTAMP(), 10);

and nothing happens. In config i have throttle 1. i sent 10 mails from this address and all got delivery. my rule was: 2 max messages / minute.


regards

4

Re: policyd

iRedMail config policyd to start 2 instances/daemons, one listens on port 10031, another listens on port 10032.

Port 10031 is used for most features, e.g. greylisting, whitelist, blacklist, blacklist HELO, etc. Set in postfix "smtpd_recipient_restrictions =".
Port 10032 is used for sender/recipient throttling only. set in postfix "smtpd_end_of_data_restrictions =".

You should start another instance/daemon first, and config postfix "smtpd_end_of_data_restrictions" to enable throttling.

5

Re: policyd

is there any tutorial that describes this? an how to?

6 (edited by icedevil 2010-09-01 03:12:28)

Re: policyd

anyone did this on freeBSD?
From the tutorials i got this: ENABLE_SENDER_THROTTLE="YES"
{http://www.iredmail.org/forum/topic608-questions-about-policyd-sender-throttle.html}
but i think this works just on linux, not on unix systems.

7

Re: policyd

I will write a short tutorial about "how to enable sender throttling" in wiki size. please be patient.

8

Re: policyd

i made it already, and i made some test until nou.
cd /usr/local/etc/rc.d/
cp policyd policyd-sender-throttle
# replace postfix_policyd_sf with policyd_sender_throttle
# replace /usr/local/etc/postfix-policyd-sf.conf with /usr/local/etc/policyd_sender_throttle.conf

echo 'policyd_sender_throttle_enable="YES"' >> /etc/rc.conf

/usr/local/etc/rc.d/policyd restart
/usr/local/etc/rc.d/policyd-sender-throttle start


until now is ok ... please tell me if i made any mistake.


regards

9

Re: policyd

Well done. smile

10 (edited by icedevil 2010-09-03 00:34:32)

Re: policyd

ZhangHuangbin wrote:

Well done. smile

Please tell me what are the original settings for postfix-policyd-sf.conf.
I don't remember if i made the backup before or after editing postfix-policyd-sf.conf.

mail[/backup-configs/usr-local-etc]# diff postfix-policyd-sf.conf /usr/local/etc/postfix-policyd-sf.conf
190c190
< WHITELISTSENDER=0
---
> WHITELISTSENDER=1
635c635
< SENDER_THROTTLE_HOST=1
---
> SENDER_THROTTLE_HOST=0
771c771
< RECIPIENTTHROTTLE=1
---
> RECIPIENTTHROTTLE=0

i'm interested about THROTTLE settings.
i ask this because it seems like in the throttle._count_tot the values are not incremented by 1, the value is incremented by 2. i send 1 email and the count value is 2, send another count value updates to 4 smile and this is not ok.

thanks again Zhang

11

Re: policyd

Reference: http://iredmail.googlecode.com/hg/iRedM … service.sh

Search 'POLICYD_SENDER_THROTTLE_CONF' in this file.

12

Re: policyd

ZhangHuangbin wrote:

Reference: http://iredmail.googlecode.com/hg/iRedM … service.sh

Search 'POLICYD_SENDER_THROTTLE_CONF' in this file.

thanks

# ---- SENDER THROTTLE ----
    # Disable recipient throttle here, it should be used in postfix
    # 'smtpd_end_of_data_restrictions'.
    perl -pi -e 's#^(SENDERTHROTTLE=)(.*)#${1}0#' ${POLICYD_CONF}


it was 0, i have the same value.
BUT why that +2 increment? is this normal? _count_cur incremented by 2 from 1 email?

13

Re: policyd

icedevil wrote:

BUT why that +2 increment? is this normal? _count_cur incremented by 2 from 1 email?

That means this email goes through both port 10031 and 10032. Try to disable it in port 10031.

14

Re: policyd

i have:
smtpd_recipient_restrictions = [...], check_policy_service inet:127.0.0.1:10031 {/usr/local/etc/postfix-policyd-sf.conf}
smtpd_end_of_data_restrictions = check_policy_service inet:127.0.0.1:10032 {/usr/local/etc/policyd_sender_throttle.conf}


you are telling me to remove check_policy_service inet:127.0.0.1:10031 from smtpd_recipient_restrictions? how i will make
greylisting, whitelist, blacklist, etc? Can i enable those features in policyd_sender_throttle.conf? In an older post you said:

"Policyd with port 10032 should ONLY provides sender throttle feature."


Please advice.
Thank you!

15

Re: policyd

Not remove them from postfix setting, but disable throttle related setting in policyd config files, so that there's only one throttling in 2 policyd instances.

16

Re: policyd

diff postfix-policyd-sf.conf policyd_sender_throttle.conf

609c609
< SENDERTHROTTLE=0
---
> SENDERTHROTTLE=1
624c624
< SENDER_THROTTLE_SASL=0
---
> SENDER_THROTTLE_SASL=1


it is already disabled in postfix-policyd-sf.conf sad

17

Re: policyd

How about "RECIPIENTTHROTTLE"?

18 (edited by icedevil 2010-09-03 18:02:31)

Re: policyd

ZhangHuangbin wrote:

How about "RECIPIENTTHROTTLE"?

mail# cat postfix-policyd-sf.conf | grep RECIPIENTTHROTTLE
RECIPIENTTHROTTLE=0
mail# cat policyd_sender_throttle.conf | grep RECIPIENTTHROTTLE
RECIPIENTTHROTTLE=0
mail#

i don't want RECIPIENTTHROTTLE activated.

19

Re: policyd

i checked all settings, double checked all config files ... nothing sad, no ideea.

20 (edited by icedevil 2010-09-05 23:29:18)

Re: policyd

here is a sample from my log file. It seems like the email is looping on localhost. look at "host".
i made an ln -s postfix-policyd-sf policyd-sender-throttle for cleaner logs. debug is 2 in /usr/local/etc/policyd_sender_throttle.conf


Sep  5 18:11:59 mail postfix-policyd-sf: rcpt=12, greylist=new, host=98.136.44.50 (n66.bullet.mail.sp1.yahoo.com), from=mailuser@yahoo.com, to=mailuser@mydomain.com, size=0
Sep  5 18:11:59 mail postfix/smtpd[5193]: NOQUEUE: reject: RCPT from n66.bullet.mail.sp1.yahoo.com[98.136.44.50]: 450 4.7.1 <mailuser@mydomain.com>: Recipient address rejected: Policy Rejection- Please try later.; from=<mailuser@yahoo.com> to=<mailuser@mydomain.com> proto=SMTP helo=<n66.bullet.mail.sp1.yahoo.com>
Sep  5 18:15:11 mail postfix-policyd-sf: rcpt=13, greylist=abuse, host=98.136.44.50 (n66.bullet.mail.sp1.yahoo.com), from=mailuser@yahoo.com, to=mailuser@mydomain.com, size=0
Sep  5 18:15:11 mail postfix/smtpd[5945]: NOQUEUE: reject: RCPT from n66.bullet.mail.sp1.yahoo.com[98.136.44.50]: 450 4.7.1 <mailuser@mydomain.com>: Recipient address rejected: Policy Rejection- Please try later.; from=<mailuser@yahoo.com> to=<mailuser@mydomain.com> proto=SMTP helo=<n66.bullet.mail.sp1.yahoo.com>
Sep  5 18:18:41 mail postfix-policyd-sf: rcpt=14, greylist=update, host=98.136.44.50 (n66.bullet.mail.sp1.yahoo.com), from=mailuser@yahoo.com, to=mailuser@mydomain.com, size=0

Sep  5 18:18:41 mail policyd-sender-throttle: DEBUG: fd: 8 policy_array[8][7]:sender=mailuser@yahoo.com
Sep  5 18:18:41 mail policyd-sender-throttle: DEBUG: fd: 8 triplet_array[8][1]: mailuser@yahoo.com
Sep  5 18:18:41 mail policyd-sender-throttle: DEBUG: fd: 8 db_charquery(): SELECT _from,_count_max,_count_cur,_date,_quota_cur,_quota_max, _time_limit,_mail_size,_count_tot,_rcpt_max,_rcpt_cur,_rcpt_tot, _log_warn, _log_panic, _abuse_tot FROM throttle WHERE _from='mailuser@yahoo.com' OR _from='@yahoo.com' ORDER BY _priority DESC LIMIT 1
Sep  5 18:18:41 mail policyd-sender-throttle: rcpt=23, throttle=new(a), host=98.136.44.50, from=mailuser@yahoo.com, to=mailuser@mydomain.com, size=2367/15728640, quota=2367/250000000, count=1/100(1), rcpt=1/3600(1), threshold=0|0|0
Sep  5 18:18:41 mail policyd-sender-throttle: DEBUG: fd: 8 db_doquery(): INSERT DELAYED INTO throttle (_date,_from,_quota_cur,_quota_max,_rcpt_max,_mail_size,_count_max,_time_limit) VALUES (1283699921, 'mailuser@yahoo.com', 2367, 250000000, 3600, 15728640, 100, 3600)
Sep  5 18:18:41 mail postfix/qmgr[4498]: 4E28C4D0A81C: from=<mailuser@yahoo.com>, size=2678, nrcpt=1 (queue active)
Sep  5 18:18:44 mail policyd-sender-throttle: DEBUG: fd: 12 policy_array[12][7]:sender=mailuser@yahoo.com
Sep  5 18:18:44 mail policyd-sender-throttle: DEBUG: fd: 12 triplet_array[12][1]: mailuser@yahoo.com
Sep  5 18:18:44 mail policyd-sender-throttle: DEBUG: fd: 12 db_charquery(): SELECT _from,_count_max,_count_cur,_date,_quota_cur,_quota_max, _time_limit,_mail_size,_count_tot,_rcpt_max,_rcpt_cur,_rcpt_tot, _log_warn, _log_panic, _abuse_tot FROM throttle WHERE _from='mailuser@yahoo.com' OR _from='@yahoo.com' ORDER BY _priority DESC LIMIT 1
Sep  5 18:18:44 mail policyd-sender-throttle: DEBUG: fd: 12 row: 0 data: mailuser@yahoo.com (recieved)
Sep  5 18:18:44 mail policyd-sender-throttle: DEBUG: fd: 12 row: 0 data: mailuser@yahoo.com (extracted)
Sep  5 18:18:44 mail policyd-sender-throttle: rcpt=25, throttle=update(a), host=127.0.0.1, from=mailuser@yahoo.com, to=mailuser@mydomain.com, size=3125/15728640, quota=5492/250000000, count=2/100(2), rcpt=2/3600(2), threshold=0|1|0
Sep  5 18:18:44 mail policyd-sender-throttle: DEBUG: fd: 12 db_doquery(): UPDATE throttle SET _rcpt_cur=_rcpt_cur+1, _rcpt_tot=_rcpt_tot+1, _quota_cur=_quota_cur+3125, _count_cur=_count_cur+1, _count_tot=_count_tot+1, _abuse_cur=0 WHERE _from='mailuser@yahoo.com'
Sep  5 18:18:44 mail postfix/qmgr[4498]: 486644D0A82F: from=<mailuser@yahoo.com>, size=3305, nrcpt=1 (queue active)
Sep  5 18:18:44 mail amavis[5399]: (05399-12) Passed CLEAN, LOCAL [98.136.44.50] [89.41.134.88] <mailuser@yahoo.com> -> <mailuser@mydomain.com>, Message-ID: <55313.54459.qm@web43515.mail.sp1.yahoo.com>, mail_id: NB9JkuPvf+Kl, Hits: -2.009, size: 2676, queued_as: 486644D0A82F, dkim_id=@yahoo.com,mailuser@yahoo.com, 2363 ms

regards