Назад | Перейти на главную страницу

Ограничение OpenVZ SMTP в час

Как мне ограничить количество SMTP-соединений в час на хост-узле для блока / 24? Например, я хочу ограничить его до 50 писем в час.

Спасибо

iptables поддерживает ограничение количества подключений / скорости. На странице руководства iptables:

connlimit Позволяет ограничить количество параллельных подключений к серверу для каждого IP-адреса клиента (или блока адресов клиента).

   [!] --connlimit-above n
          Match if the number of existing connections is (not) above n.

   --connlimit-mask prefix_length
          Group hosts using the prefix length. For IPv4, this must be a number between (including) 0 and 32. For IPv6, between 0 and 128.

   Examples:

   # allow 2 telnet connections per client host
          iptables -A INPUT -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT

   # you can also match the other way around:
          iptables -A INPUT -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT

   # limit the number of parallel HTTP requests to 16 per class C sized network (24 bit netmask)
          iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16 --connlimit-mask 24 -j REJECT

   # limit the number of parallel HTTP requests to 16 for the link local network
          (ipv6) ip6tables -p tcp --syn --dport 80 -s fe80::/64 -m connlimit --connlimit-above 16 --connlimit-mask 64 -j REJECT

limit Этот модуль соответствует с ограниченной скоростью с использованием фильтра корзины токенов. Правило, использующее это расширение, будет соответствовать, пока не будет достигнут этот предел (если не используется флаг «!»). Его можно использовать в сочетании с целью LOG, например, для ограниченного ведения журнала.

   --limit rate[/second|/minute|/hour|/day]
          Maximum average matching rate: specified as a number, with an optional ‘/second’, ‘/minute’, ‘/hour’, or ‘/day’ suffix; the default is 3/hour.

   --limit-burst number
          Maximum initial number of packets to match: this number gets recharged by one every time the limit specified above is not reached, up to this number; the default is 5.