HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=27)
-   -   Adding rules to IPTables/Postfix ports (http://www.howtoforge.com/forums/showthread.php?t=36299)

davew 11th June 2009 17:44

Adding rules to IPTables/Postfix ports
 
I need to accept smtp traffic on additional ports to 25 because some of my clients have ISPs that block port 25 traffic to anything other than their ISPs mail servers.

A while ago I implemented this with a quick workaround using IPTables where I added the rule...
-A PREROUTING -p tcp -m tcp --dport 587 -j REDIRECT --to-ports 25

to /etc/sysconfig/iptables

When I turn the firewall on in ISPConfig 3, the bastille script (I assume) rewrites iptables and discards my redirect.

Is there an easy way to add my rerouting rule so it "sticks" or any other way of allowing postfix to listen on more than one port ? I assume I need to use /usr/local/ispconfig/server/conf-custom/ for the former ?

Am I correct in thinking that this prerouting rule also allows fail2ban (on port 25) to work correctly for this new port ?

till 11th June 2009 19:55

There is no way implemented to add any custom rules. It might get added in later versions.

davew 11th June 2009 21:26

OK, thanks. I'll change the postfix config to get it to listen on both ports then.

rbartz 2nd September 2009 08:37

Quote:

Originally Posted by till (Post 193509)
There is no way implemented to add any custom rules. It might get added in later versions.

Actually, there may be an easy way, at least on Fedora Linux most or all Cores and maybe in all Linux distros using Bastille.

In /etc/Bastille you should have or can create a directory named firewall.d. In that directory, you can add a file that is run on server reboot, thus restoring your "special" rules such as blocking a Nigerian ISP that has some nasty fellows who are constantly probing your server....
======================
cd /etc/Bastille
mkdir firewall.d
vi post-rule-setup.sh

INSERT the iptables COMMANDS you need, for example

iptables -I INPUT -m iprange --src-range 82.128.0.0-82.128.127.255 -j DROP
iptables -I OUTPUT -m iprange --dst-range 82.128.0.0-82.128.127.255 -j DROP
=======================

Save the file, then when iptables starts at boot it loads these rules.

I have found this to be an effective way to permanently deal with a lot of the server brute-force-attacks originating again and again in some countries, and to forever block someone who used cracked SMTP logins to spam.

Any iptables rules in the file are run, but be sure that the rules are valid and tested from the command line so that you don't break iptables on boot.

Richard


All times are GMT +2. The time now is 16:23.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.