Hostxpeed
Login Get Started →
Security

How to Block Port Scanning

4 min read
27 views
Jun 12, 2026

Using iptables with psd module

sudo iptables -A INPUT -m psd --psd-weight-threshold 21 -j DROP

Using Fail2ban with recidive jail

sudo nano /etc/fail2ban/jail.local

Add recidive jail after SSH configuration:

[recidive]
enabled = true
logpath = /var/log/fail2ban.log
maxretry = 3
bantime = 604800 # 1 week

Using Port Knocking (Reverse)

Configure knockd to close ports when scanning detected.

Was this article helpful?