Skip to content
Sai Gopal edited this page Jul 15, 2015 · 2 revisions

Getting Started

We will be setting up ratelimitd to allow 10 mails per minute per ip address.

Assumptions

  • You already have postfix server installed and configured.
  • You already have redis server installed and configured to listen on localhost and all other settings to default.
  • You have installed the ratelimitd on the system.

Configuration

  • Open/Create the conf file present at /opt/ratelimitd/etc/ratelimitd.conf
sudo vim /opt/ratelimitd/etc/ratelimitd.conf
  • Add the following snippet to the conf file as is
[Server]
Host: localhost
Port: 12345
PidFile: /tmp/ratelimitd.pid
[RedisConfig]
RedisMasterHost: 127.0.0.1
RedisMasterPort: 6379
RedisMasterAuth: None
RedisMasterDB: 0
RedisSlaveHost: 127.0.0.1
RedisSlavePort: 6379
RedisSlaveAuth: None
RedisSlaveDB: 0
[Policies]
ActivePolicies: IPPolicy
[IPPolicy]
Enforce: False
RejectMessage: 550 5.4.6 IP Quota Exceeded
ProfileLookupMethod: None
ProfileCacheTime: 30
[IPPolicy-Profiles]
default: 10,60
  • Start the ratelimitd server
sudo service ratelimitd start
  • Note: We have configured the ratelimitd server to track quota but not reject any mail. [ Enforce: False]

  • Integrate ratelimitd with postfix

    • open postfix main.cf
      sudo vi /etc/postfix/main.cf
      
    • In smtpd_recipient_restrictions settings add
      smtpd_recipient_restrictions =  ....
                                          check_policy_service inet:127.0.0.1:12345
                                        ....
      
  • Reload postfix

sudo service postfix reload
  • Follow MailLog
sudo tailf /var/log/maillog
  • If an ipaddress`s quota is within limits then you would see this in the log file
<TimeStamp> <Hostname> <Path>[PID]: IPPolicy IP: 1.2.3.4 Quota: (1/50) Profile: default Action: accept
  • If an ipaddress`s quota has exceeded its limits then you would see this in the log file
<TimeStamp> <Hostname> <Path>[PID]: IPPolicy IP: 1.2.3.4 Quota: Exceeded Profile: default Action: reject
  • To reject mails then in change /opt/ratelimitd/etc/ratelimitd.conf
Enforce: True
  • And Then
    sudo service ratelimitd restart
    

Clone this wiki locally