<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="https://uname.pingveno.net/blog/index.php/feed/rss2/xslt" ?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title># uname -a - Mot-clé - cluebringer</title>
    <link>https://uname.pingveno.net/blog/index.php/</link>
    <atom:link href="https://uname.pingveno.net/blog/index.php/feed/tag/cluebringer/rss2" rel="self" type="application/rss+xml" />
    <description>Le blog de uname.pingveno.net</description>
    <language>fr</language>
    <pubDate>Tue, 18 Aug 2026 13:46:21 +0200</pubDate>
    <copyright>Mathieu Pellegrin</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Dotclear</generator>
          <item>
        <title>Configure sender rate limits to prevent spam, using cluebringer (policyd) with Postfix</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/03/11/Configure-sender-rate-limits-to-prevent-spam%2C-using-cluebringer-%28policyd%29-with-Postfix</link>
        <guid isPermaLink="false">urn:md5:11c6569b7382d3cd707a41e60deae65c</guid>
        <pubDate>Fri, 13 Mar 2015 09:18:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>cluebringer</category>
                  <category>debian</category>
                  <category>mail</category>
                  <category>policyd</category>
                  <category>postfix</category>
                  <category>server</category>
                <description>&lt;p&gt;This small how-to will show you how to configure cluebringer (aka policyd) to set a per-hour/per-user limit for sent mails. Note that sending to multiple recipient will count like multiple mails were sent.&lt;/p&gt;

&lt;p&gt;This how-to is Debian-oriented but should apply to any unix operating system.&lt;/p&gt;          &lt;h3&gt;Requirements&lt;/h3&gt;

&lt;p&gt;A mail server with Postfix installed.&lt;/p&gt;

&lt;h3&gt;Installation&lt;/h3&gt;

&lt;p&gt;Install a DBMS (MySQL for instance), cluebringer, and cluebringer-webui&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
apt-get install mysql-server cluebringer cluebringer-mysql cluebringer-webui&lt;/pre&gt;

&lt;p&gt;Note that cluebringer-webui will install apache as a dependency if you don&amp;#8217;t already have a webserver.&lt;/p&gt;

&lt;h3&gt;Set-up the Cluebringer database&lt;/h3&gt;

&lt;p&gt;Get the initial database schema that correspond to your DBMS, for instance mysql&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
cp /usr/share/doc/postfix-cluebringer/database/policyd-db.mysql.gz ~/ &amp;amp;&amp;amp; gunzip ~/policyd-db.mysql.gz&lt;/pre&gt;

&lt;p&gt;Create the database, and populate it with the initial dump&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
# cd  ~/ &amp;amp;&amp;amp; mysql -u root -p
mysql&amp;gt; CREATE DATABASE cluebringer;
mysql&amp;gt; CREATE USER 'cluebringer'@'localhost' IDENTIFIED BY 'mypassword';
mysql&amp;gt; GRANT ALL PRIVILEGES ON cluebringer.* TO 'cluebringer'@'localhost';
mysql&amp;gt; \. policyd-db.mysql
mysql&amp;gt; quit
mysql&amp;gt; Bye
&lt;/pre&gt;

&lt;p&gt;Note that on Debian I had to modify the dump to make it work, &lt;em&gt;TYPE=InnoDB&lt;/em&gt; was rejected by MySQL as an invalid syntax.&lt;/p&gt;

&lt;h3&gt;Configure Cluebringer&lt;/h3&gt;

&lt;p&gt;Add your DBMS credentials to the file &lt;strong&gt;/etc/cluebringer/cluebringer.conf&lt;/strong&gt;&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
DSN=DBI:mysql:dbname=cluebringer;host=localhost

DB_Type=mysql
DB_Host=localhost
DB_Port=3306
DB_Name=cluebringer
Username=cluebringer
Password=mypassword&lt;/pre&gt;

&lt;p&gt;And start it&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
service postfix-cluebringer start&lt;/pre&gt;

&lt;h3&gt;Configure Cluebringer webui&lt;/h3&gt;

&lt;p&gt;Configure the file &lt;strong&gt;/etc/cluebringer/cluebringer-webui.conf&lt;/strong&gt; with your DBMS credentials&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php

$DB_DSN=&quot;mysql:host=localhost;dbname=cluebringer&quot;;
$DB_USER=&quot;cluebringer&quot;;
$DB_PASS=&quot;mypassword&quot;;&lt;/pre&gt;

&lt;p&gt;Cluebringer Webui needs a web server to run. Copy the sample configuration from the package documentation&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
cp /usr/share/doc/postfix-cluebringer-webui/examples/httpd/cluebringer-httpd.conf /etc/apache2/conf.d/&lt;/pre&gt;

&lt;p&gt;Restart Apache&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
service apache2 restart&lt;/pre&gt;

&lt;p&gt;You may need to adjust a few things to access it from the outside. If you a really lazy, just make a ssh tunnel to access the webserver from localhost&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
ssh -L 8008:localhost:80 mylogin@mymailserver&lt;/pre&gt;

&lt;p&gt;Don&amp;#8217;t forget&amp;#160;: you have to make this tunnel from the outside, do not run this command on server, it won&amp;#8217;t work.&lt;/p&gt;

&lt;p&gt;You should now be able to open http://localhost:8080/ and see your fresh new Cluebinger Webui&amp;#160;!&lt;/p&gt;

&lt;h3&gt;Configure Cluebringer using its webui&lt;/h3&gt;

&lt;h4&gt;Add a policy&lt;/h4&gt;

&lt;p&gt;Under &lt;strong&gt;Policies&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Main&lt;/strong&gt;, disable Test policy (select policy and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Change&lt;/strong&gt; and switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;yes&lt;/strong&gt;, validate)&lt;/p&gt;

&lt;p&gt;Add a new policy&amp;#160;: &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;, give it a name and a description&lt;/p&gt;

&lt;p&gt;Activate your new policy&amp;#160;: select policy and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Change&lt;/strong&gt; (switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;Add a new member to your policy&amp;#160;: select it and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Members&lt;/strong&gt;, and then &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;. Specify &lt;strong&gt;any&lt;/strong&gt; as source and &lt;strong&gt;any&lt;/strong&gt; as destination.&lt;/p&gt;

&lt;p&gt;Go back to your policy, choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Members&lt;/strong&gt;, and the select your member, do &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Change&lt;/strong&gt;, and activate your new member (switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;).&lt;/p&gt;

&lt;h4&gt;Add a quota&lt;/h4&gt;

&lt;p&gt;Under &lt;strong&gt;Quotas&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Configure&lt;/strong&gt;, disable Test quotas.&lt;/p&gt;

&lt;p&gt;Add a new quota&amp;#160;: Choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Name&amp;#160;: whatever you want&lt;/li&gt;
	&lt;li&gt;Track&amp;#160;: &lt;strong&gt;user@domain&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Period (seconds)&amp;#160;: &lt;strong&gt;3600&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Link to policy&amp;#160;: specify the policy you created here&lt;/li&gt;
	&lt;li&gt;Verdict&amp;#160;: &lt;strong&gt;Defer&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Data&amp;#160;: set a custom error message here&lt;/li&gt;
	&lt;li&gt;Comment&amp;#160;: whatever you want&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Activate your quota&amp;#160;: switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Add a limit to your quota&amp;#160;: select your quota, and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Limits&lt;/strong&gt;, then &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Type&amp;#160;: &lt;strong&gt;MessageCount&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Counter Limit&amp;#160;: &lt;strong&gt;200&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Activate your limit&amp;#160;: switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;Configure Postfix to call Cluebringer for each mail sent&lt;/h3&gt;

&lt;p&gt;Open &lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; and locate the line &lt;strong&gt;smtpd_sender_restrictions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Add &lt;strong&gt;check_policy_service inet:127.0.0.1:10031&lt;/strong&gt; at the end of the line, for instance&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf&lt;strong&gt;, check_policy_service inet:127.0.0.1:10031&lt;/strong&gt;&lt;/pre&gt;

&lt;p&gt;If the line does not exists, simply add it.&lt;/p&gt;

&lt;p&gt;Don&amp;#8217;t forget to restart Postfix&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
service postfix restart&lt;/pre&gt;

&lt;h3&gt;Check your config&lt;/h3&gt;

&lt;p&gt;You can now send some mails to see what happens. To check if these mails are passed to Cluebringer, connect to MySQL as the cluebringer user&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
# mysql -u cluebringer -p cluebringer&lt;/pre&gt;

&lt;p&gt;And execute the query&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
mysql&amp;gt; SELECT * FROM quotas_tracking;&lt;/pre&gt;

&lt;p&gt;You should see the value LastUpdate and Counter updating when sending a mail. Note that sending to multiple recipient will count like multiple mails were sent.&lt;/p&gt;

&lt;h3&gt;Pitfalls, bleeding edges, etc&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Cluebringer versions prior to 2.1.x does not support IPv6&lt;/strong&gt;, your customers won&amp;#8217;t be able to send any mail if they have an IPv6 connection.&lt;/p&gt;

&lt;p&gt;Unfortunately, the Debian stable version (wheezy) provides Cluebringer 2.0.10 within its repositories, as well as the experimental release of Debian (sid). As an alternative, you should consider &lt;a href=&quot;http://wiki.policyd.org/download&quot;&gt;installing the 2.1.x experimental Cluebringer&lt;/a&gt; from official website instead of Debian packages from repositories.&lt;/p&gt;

&lt;h3&gt;References&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://wiki.policyd.org/installing&quot; hreflang=&quot;en&quot;&gt;Installing Policyd&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://imanudin.net/2014/09/09/zimbra-tips-how-to-configure-rate-limit-sending-message-on-policyd/&quot; hreflang=&quot;en&quot;&gt;Configuring Policyd for Zimbra&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://jrklein.com/2014/03/09/debian-wheezy-postfix-cluebringer-policyd-v2-ipv6/&quot; hreflang=&quot;en&quot;&gt;Debian, Cluebringer, IPv6&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
              </item>
      </channel>
</rss>
