HOWTO fail2ban with OpenVPN

From Fail2ban
Revision as of 10:49, 24 October 2016 by Charles (Talk | contribs) (Page creation)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page describes how to set up fail2ban with OpenVPN 2.3.4 (tested on Debian 8 Jessie)

Create /etc/fail2ban/filter.d/openvpn.local containing:

# Fail2Ban filter for selected OpenVPN rejections


# Example messages (other matched messages not seen in the testing server's logs):
# Fri Sep 23 11:55:36 2016 TLS Error: incoming packet authentication failed from [AF_INET]
# Thu Aug 25 09:36:02 2016 TLS Error: TLS handshake failed

failregex = ^ TLS Error: incoming packet authentication failed from \[AF_INET\]<HOST>:\d+$
            ^ <HOST>:\d+ Connection reset, restarting
            ^ <HOST>:\d+ TLS Auth Error
            ^ <HOST>:\d+ TLS Error: TLS handshake failed$
            ^ <HOST>:\d+ VERIFY ERROR

ignoreregex = 

Create /etc/fail2ban/jail.d/openvpn containing:

# Fail2Ban configuration fragment for OpenVPN

enabled  = true
port     = 1194
protocol = udp
filter   = openvpn
logpath  = /var/log/openvpn.log
maxretry = 3

To effect the configuration change:

service fail2ban restart

To test the configuration change, check /var/log/fail2ban.log initially for service start messages and later for WARNING [openvpn] Ban and Unban messages.