• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

iptables rule to block all outgoing mail sent via perl (or other) scripts

StéphanS

Regular Pleskian
Mail should always be sent via qmail or Postfix.
In order to be able to track any spammers and to use Parallels Premium Outgoing Antispam.

I have created the following iptable rules to enforce this for Postfix:

iptables -A OUTPUT -d 127.0.0.1 -p tcp -m tcp --dport 25 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --gid-owner postfix -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --gid-owner mailman -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --uid-owner root -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -j REJECT --reject-with icmp-port-unreachable


Would it be possible for the Plesk Firewall Module to have such a rule so we can better control the mailflow?


Thanks!
 
Mail should always be sent via qmail or Postfix.
In order to be able to track any spammers and to use Parallels Premium Outgoing Antispam.

I have created the following iptable rules to enforce this for Postfix:




Would it be possible for the Plesk Firewall Module to have such a rule so we can better control the mailflow?


Thanks!


Hello! My server was compromised with a ugly Perl script and spammed out tons of mails.
This IPTABLES rules come great for stopping them, have you tested them in qmail ?

Thanks for sharing.

Greetings!
 
Hello! My server was compromised with a ugly Perl script and spammed out tons of mails.
This IPTABLES rules come great for stopping them, have you tested them in qmail ?

Thanks for sharing.

Greetings!

For qmail it should be:

Code:
iptables -A OUTPUT -d 127.0.0.1 -p tcp -m tcp --dport 25 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --gid-owner qmail -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --gid-owner mailman -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --uid-owner root -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -j REJECT --reject-with icmp-port-unreachable


I have not tested this though, so let me know if it worked for you!
 
Hi, a good idea
I've a question about these rules, could add a LOG, something like

-j LOG --log-prefix "Alert QMAIL-REJECTED"

in last rule for example?

Oh, and another question, does it work with qmail?

Thanks
 
Hi, a good idea
I've a question about these rules, could add a LOG, something like

-j LOG --log-prefix "Alert QMAIL-REJECTED"

in last rule for example?


If you have a LOG chain then this should work as intended.
Please refer to http://www.thegeekstuff.com/2012/08/iptables-log-packets/


Oh, and another question, does it work with qmail?


For qmail it should be:

Code:
iptables -A OUTPUT -d 127.0.0.1 -p tcp -m tcp --dport 25 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --gid-owner qmail -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --gid-owner mailman -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --uid-owner root -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -j REJECT --reject-with icmp-port-unreachable


I have not tested this though, so let me know if it worked for you!
 
Last edited:
Thanks . I think these rules should enabled by default . I know here is linux thread but any equivalent rules for Windows ?
 
Back
Top