@Pleskie,
It has taken you some posts to get you somewhere, but actually, your questions are not completely answered.
In fact, what you really aim to do is "closing" ports for all USED services.
Well, in the answers, I do not read a lot of practical tips and answers.
It is quite simple, let´s start with some golden rules:
a) do not edit iptables via the command line, instead use something with a GUI, his is less error-prone and will hence prevent some issues (like locking yourself out of the system)
b) use the Plesk Firewall Extension: it already contains some preconfigured firewall rules for specific services, like Tomcat, PostgreSql etc.
Just disable (rule: deny) the following:
- Customer & Business Manager payment gateways
- Single Sign-On
- Mail password change service
- Tomcat administrative interface
- Samba (file sharing in Windows networks) (an extension that you should not use!)
- Plesk VPN (again, an extension that you should not use)
Just limit (rule: allow for, deny all others) the following:
- FTP server (limit to your personal IP and other IPs that should have FTP access)
- Plesk Installer (limit to your personal IP)
- Plesk administrative interface (limit to your personal IP and those IPs of your customers)
- MySQL server (limit to 127.0.0.1, see note 1 below)
- PostgreSQL server (limit to 127.0.0.1 or completely deny, because you will probably not use this)
- SSH (secure shell) server (limit to your personal IP, but see note 2 below!)
Note 1: strictly, this is not necessary, you can do this via "Tools & Settings > Applications & Databases > Database Hosting Preferences". However, a firewall based limit to localhost is something that can be recommended, it just enhances security.
Note 2: only you or a sysadmin should have SSH access. However, the Plesk Migrator has the nasty habit of using ssh. So, whenever trying to migrate domains to another server, just add the IP of the target server (and do the same in the firewall on the target server: add the IP of the source server).
That is about it, everything else can be "open".
However, it is always good to
- create custom rules with "bad" and "notorious" IPs (there is one specific reason why this is good, I will explain later, in point c)
- apply strict security settings for the entire server, for instance, at least at the level provided with the command line utility called pci_compliance_resolver
Note that one can discuss each individual port, but that really makes no sense and/or is completely inefficient.
For instance, port 12768 is ONLY relevant if you use Postfix (and otherwise it is not) AND custom firewall rules for port 12768 are barely relevant, when PCI compliant settings apply.
As another illustration, one can spend a lot of time on firewall rules for "outgoing traffic", but that actually is not worth the time. All trouble is inbound, at least that is often the case.
c) Enable Fail2Ban !!!!!
Fail2Ban is a log scanner, resulting in an automated adjustment of iptables rules: specific IPs are blocked during a specific interval.
Well, you can imagine by now that Fail2Ban becomes rather busy when the custom rules "bad" and "notorious" are not explicitly present in the Plesk Firewall.
Those bad/notorious IPs are essentially IPs that try to brute force (read: try over and over again) and Fail2Ban has little power over them, except for blocking them temporarily.
Using Fail2Ban in the case of bad/notorious IPs is not only ineffective, it will also cause a performance penalty.
So, creating the custom "bad" and "notorious" rules simply results in those IPs in being blocked permanently, not even entering the logs, that are scanned by Fail2Ban.
Your system is safer and Fail2Ban gets a holiday.
However, you cannot do everything by hand, you cannot enter all bad/notorious IPs in the Plesk Firewall (there are literally millions of those IPs), so Fail2Ban fine tuning is also required.
Go to "Tools & Settings > Security > Fail2Ban > Jails > Recidive (select jail) > Change Settings (click)" and
- change the number for maxretry to a lower value (3 is often a good value)
- increase the ban period (for instance, take a month, which should be 2419200 seconds)
- keep track of fail2ban.log and look for the IPs with the text "recidive" and "ban" (if one IP is recurring, even after previous bans with the recidive jail, add the IP to Plesk Firewall: add them manually to the "bad" or "notorious" custom rule)
and that is about it.
Hope the above helps a bit........
Ciao!