Why Use PSAD
Even if you have a firewall to guard your doors, it is possible to try brute-forcing your way in any of the guarded doors. We want to monitor all network activity to detect potential intrusion attempts, such has repeated attempts to get in, and block them.How It Works
I can’t explain it any better than user FINESEC did:Fail2BAN scans log files of various applications such as apache, ssh or ftp and automatically bans IPs that show the malicious signs such as automated login attempts. PSAD on the other hand scans iptables and ip6tables log messages (typically /var/log/messages) to detect and optionally block scans and other types of suspect traffic such as DDoS or OS fingerprinting attempts. It’s ok to use both programs at the same time because they operate on different level.
Installation and Configuration
Configure PSAD
Review and update configuration options in
/etc/psad/psad.conf. Pay special attention to these settings:| Setting | Set To |
|---|---|
EMAIL_ADDRESSES | your email address(es) |
HOSTNAME | your server’s hostname |
EXPECT_TCP_OPTIONS | EXPECT_TCP_OPTIONS Y; |
ENABLE_PSADWATCHD | ENABLE_PSADWATCHD Y; |
ENABLE_AUTO_IDS | ENABLE_AUTO_IDS Y; |
ENABLE_AUTO_IDS_EMAILS | ENABLE_AUTO_IDS_EMAILS Y; |
Check the PSAD documentation for more details on configuration options.
Configure UFW to Log Traffic
Make backups first:Edit both files:Example of what the end of the file should look like:
/etc/ufw/before.rules/etc/ufw/before6.rules
We’re adding a log prefix to all the iptables logs. This prefix will be useful for separating iptables logs to their own file if needed.
Analyze iptables Rules
Verify that PSAD can properly analyze your iptables rules:You should see output like:
If there were any issues, you will get an e-mail with the error.