LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-25-2014, 01:19 AM   #1
ipv89
LQ Newbie
 
Registered: Jun 2014
Posts: 10

Rep: Reputation: Disabled
Help with ip tables


Hi guys I have just started using fail2ban with iptables and fail to ban seams to be doing its job but when the rule is added to iptables it is still serving webpages to the ip address that is banned.

This is the output of sudo iptables -l

Quote:
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-apache-noscript tcp -- anywhere anywhere multiport dports http,https
fail2ban-apache-auth tcp -- anywhere anywhere tcp dpt:http
fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain fail2ban-apache-auth (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere

Chain fail2ban-apache-noscript (1 references)
target prot opt source destination
DROP all -- 124-197-23-113.callplus.net.nz anywhere
RETURN all -- anywhere anywhere

Chain fail2ban-ssh (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
 
Old 06-25-2014, 11:24 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Couple of things.
What version of fail2ban is this?
Which jail is causing you concern?
What does /var/log/fail2ban.log say is happening?
Possibly being "unbanned"?

Post the entries from /etc/fail2ban/jail.local please.

See also
https://www.linuxquestions.org/quest...ail2ban-36031/ for other debugging techniques, eg:
Code:
fail2ban-regex /path/to/apache/access_log  /etc/fail2ban/filter.d/<your_jail>.conf
Please let us know...

Edit: And Welcome to LQ!

Last edited by Habitual; 06-25-2014 at 11:25 AM.
 
Old 06-25-2014, 03:09 PM   #3
ipv89
LQ Newbie
 
Registered: Jun 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Smile

Thank you,

It should be 0.8.13 how can I confirm this?

The jail that is being activated is apache-noscript

Fail2ban log -
Quote:


.197.23.113
2014-06-25 01:09:38,712 fail2ban.filter : DEBUG Found 124.197.23.113
2014-06-25 01:09:38,712 fail2ban.filter : DEBUG Currently have failures from 1 IPs: [u'124.197.23.113']
2014-06-25 01:09:38,713 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 01:09:38,739 fail2ban.actions: WARNING [apache-noscript] 124.197.23.113 already banned
2014-06-25 01:09:39,659 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 01:09:39,659 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 01:09:39,659 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 01:09:39,682 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 01:09:39,682 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 01:09:39,683 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 01:09:39,714 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 01:09:39,714 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 01:09:39,714 fail2ban.filter : DEBUG Processing line with time:1403676578.0 and ip:124.197.23.113
2014-06-25 01:09:39,715 fail2ban.filter : DEBUG Found 124.197.23.113
2014-06-25 01:09:39,715 fail2ban.filter : DEBUG Currently have failures from 1 IPs: [u'124.197.23.113']
2014-06-25 01:09:39,715 fail2ban.filter : DEBUG Processing line with time:1403676578.0 and ip:124.197.23.113
2014-06-25 01:09:39,715 fail2ban.filter : DEBUG Found 124.197.23.113
2014-06-25 01:09:39,715 fail2ban.filter : DEBUG Currently have failures from 1 IPs: [u'124.197.23.113']
2014-06-25 01:09:39,716 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 01:09:39,741 fail2ban.actions: WARNING [apache-noscript] 124.197.23.113 already banned
2014-06-25 01:09:43,618 fail2ban.filter : DEBUG Got event: 1 for /var/log/auth.log
2014-06-25 01:09:43,618 fail2ban.filter : DEBUG File changed: /var/log/auth.log
2014-06-25 01:09:43,619 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 01:09:46,622 fail2ban.filter : DEBUG Got event: 1 for /var/log/auth.log
2014-06-25 01:09:46,622 fail2ban.filter : DEBUG File changed: /var/log/auth.log
2014-06-25 01:09:46,623 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 01:12:43,781 fail2ban.filter : DEBUG Got event: 1 for /var/log/auth.log
2014-06-25 01:12:43,781 fail2ban.filter : DEBUG File changed: /var/log/auth.log
2014-06-25 01:12:43,782 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 01:19:33,292 fail2ban.actions: WARNING [apache-noscript] Unban 124.197.23.113
2014-06-25 01:19:33,293 fail2ban.actions.action: DEBUG iptables -n -L INPUT | grep -q fail2ban-apache-noscript
2014-06-25 01:19:33,297 fail2ban.actions.action: DEBUG iptables -n -L INPUT | grep -q fail2ban-apache-noscript returned successfully
2014-06-25 01:19:33,297 fail2ban.actions.action: DEBUG iptables -D fail2ban-apache-noscript -s 124.197.23.113 -j DROP
2014-06-25 01:19:33,301 fail2ban.actions.action: DEBUG iptables -D fail2ban-apache-noscript -s 124.197.23.113 -j DROP returned successfully
2014-06-25 01:39:03,225 fail2ban.filter : DEBUG Got event: 1 for /var/log/auth.log
2014-06-25 01:39:03,225 fail2ban.filter : DEBUG File changed: /var/log/auth.log
2014-06-25 01:39:03,226 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 01:57:03,191 fail2ban.filter : DEBUG Got event: 1 for /var/log/auth.log
2014-06-25 01:57:03,192 fail2ban.filter : DEBUG File changed: /var/log/auth.log
2014-06-25 01:57:03,192 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:09:02,874 fail2ban.filter : DEBUG Got event: 1 for /var/log/auth.log
2014-06-25 02:09:02,874 fail2ban.filter : DEBUG File changed: /var/log/auth.log
2014-06-25 02:09:02,875 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:47:25,998 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:47:25,999 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:47:25,999 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:47:26,036 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:47:26,036 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:47:26,037 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:47:26,047 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:47:26,047 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:47:26,048 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:50:50,182 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:50:50,182 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:50:50,182 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:50:50,218 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:50:50,218 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:50:50,219 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:50:50,233 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:50:50,233 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:50:50,234 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:50:51,183 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:50:51,184 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:50:51,184 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:50:51,219 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:50:51,219 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:50:51,219 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:50:51,235 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:50:51,235 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:50:51,235 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:50:56,189 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:50:56,189 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:50:56,190 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:50:56,226 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:50:56,226 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:50:56,227 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:50:56,239 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:50:56,239 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:50:56,239 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:21,267 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:21,267 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:21,268 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:21,302 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:21,302 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:21,303 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:21,316 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:21,316 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:21,317 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:24,271 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:24,271 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:24,271 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:24,305 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:24,305 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:24,306 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:24,319 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:24,319 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:24,320 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:33,279 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:33,279 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:33,280 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:33,313 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:33,313 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:33,314 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:33,327 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:33,327 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:33,328 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:34,280 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:34,280 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:34,281 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:34,314 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:34,314 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:34,315 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:34,328 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:34,328 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:34,329 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:41,287 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:41,287 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:41,288 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:41,321 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:41,321 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:41,322 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:52:41,336 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:52:41,336 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:52:41,337 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:54:01,360 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:54:01,361 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:54:01,361 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:54:01,392 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:54:01,393 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:54:01,394 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:54:01,410 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:54:01,411 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:54:01,411 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:54:05,364 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:54:05,365 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:54:05,365 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:54:05,397 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:54:05,397 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:54:05,398 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:54:05,414 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:54:05,414 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:54:05,414 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:54:11,371 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:54:11,372 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:54:11,372 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:54:11,403 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:54:11,403 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:54:11,404 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 02:54:11,419 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 02:54:11,420 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 02:54:11,420 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 08:12:52,205 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 08:12:52,205 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 08:12:52,206 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 08:12:52,244 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 08:12:52,244 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 08:12:52,245 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 08:12:53,181 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 08:12:53,181 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 08:12:53,182 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 11:39:01,341 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 11:39:01,341 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 11:39:01,342 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 11:39:01,372 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 11:39:01,372 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 11:39:01,372 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 11:39:01,381 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 11:39:01,381 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 11:39:01,382 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 12:26:29,898 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 12:26:29,898 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 12:26:29,899 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 12:26:29,936 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 12:26:29,936 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 12:26:29,937 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-25 12:26:29,951 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-25 12:26:29,951 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-25 12:26:29,952 fail2ban.filter.datedetector: DEBUG Sorting the template list
Jails -
Quote:
[ssh]

enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 6

[dropbear]

enabled = false
port = ssh
filter = sshd
logpath = /var/log/dropbear
maxretry = 6

# Generic filter for pam. Has to be used with action which bans all ports
# such as iptables-allports, shorewall
[pam-generic]

enabled = false
# pam-generic filter can be customized to monitor specific subset of 'tty's
filter = pam-generic
# port actually must be irrelevant but lets leave it all for some possible uses
port = all
banaction = iptables-allports
port = anyport
logpath = /var/log/auth.log
maxretry = 6

[xinetd-fail]

enabled = false
filter = xinetd-fail
port = all
banaction = iptables-multiport-log
logpath = /var/log/daemon.log
maxretry = 2


[ssh-ddos]

enabled = false
port = ssh
filter = sshd-ddos
logpath = /var/log/auth.log
maxretry = 6

#
# HTTP servers
#

[apache]

enabled = true
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 2
action = iptables[name=apache-auth, port=80, protocol=tcp]


# default action is now multiport, so apache-multiport jail was left
# for compatibility with previous (<0.7.6-2) releases
[apache-multiport]
enabled = true
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 2
action = hostsdeny[name=fail2ban, port=80, protocol=tcp]

#[apache-phpmyadmin]
#enabled = true
#port = http,https
#filter = apache-phpmyadmin
#logpath = /var/log/apache*/*error.log
#maxretry = 3

[apache-noscript]

enabled = true
port = http,https
filter = apache-noscript
logpath = /var/log/apache*/*error.log
maxretry = 2

[apache-overflows]

enabled = false
port = http,https
filter = apache-overflows
logpath = /var/log/apache*/*error.log
maxretry = 2

#
# FTP servers
#

[vsftpd]

enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = vsftpd
logpath = /var/log/vsftpd.log
# or overwrite it in jails.local to be
# logpath = /var/log/auth.log
# if you want to rely on PAM failed login attempts
# vsftpd's failregex should match both of those formats
maxretry = 6


[proftpd]

enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = proftpd
logpath = /var/log/proftpd/proftpd.log
maxretry = 6


[pure-ftpd]

enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = pure-ftpd
logpath = /var/log/auth.log
maxretry = 6


[wuftpd]

enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = wuftpd
logpath = /var/log/auth.log
maxretry = 6


#
# Mail servers
#

[postfix]

enabled = false
port = smtp,ssmtp
filter = postfix
logpath = /var/log/mail.log


[couriersmtp]

enabled = false
port = smtp,ssmtp
filter = couriersmtp
logpath = /var/log/mail.log


#
# Mail servers authenticators: might be used for smtp,ftp,imap servers, so
# all relevant ports get banned
#

[courierauth]

enabled = false
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter = courierlogin
logpath = /var/log/mail.log


[sasl]

enabled = false
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter = sasl
# You might consider monitoring /var/log/mail.warn instead if you are
# running postfix since it would provide the same log lines at the
# "warn" level but overall at the smaller filesize.
logpath = /var/log/mail.log

[dovecot]

enabled = false
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter = dovecot
logpath = /var/log/mail.log

# DNS Servers
Thanks for your help
 
Old 06-25-2014, 04:09 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
fail2ban-client -V | head -1
will show us the version.

What does
Code:
iptables -L fail2ban-apache-noscript -n
show?

What are the contents of /etc/fail2ban/filter.d/apache-noscript.conf ?

What does
Code:
fail2ban-regex /var/log/apache*/*error.log /etc/fail2ban/filter.d/apache-noscript.conf
show under Results?

"Sorry, no match" or "Success, the total number of match is xx"??

subscribed with interest...
 
Old 06-27-2014, 01:15 AM   #5
ipv89
LQ Newbie
 
Registered: Jun 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
Code:
fail2ban-client -V | head -1
will show us the version.

What does
Code:
iptables -L fail2ban-apache-noscript -n
show?

What are the contents of /etc/fail2ban/filter.d/apache-noscript.conf ?

What does
Code:
fail2ban-regex /var/log/apache*/*error.log /etc/fail2ban/filter.d/apache-noscript.conf
show under Results?

"Sorry, no match" or "Success, the total number of match is xx"??

subscribed with interest...
Sorry for the late reply I have been crazy busy with work

Cool it is 0.8.6

iptables -L fail2ban-apache-noscript -n shows

Quote:
target prot opt source destination
DROP all -- 124.197.23.113 0.0.0.0/0
RETURN all -- 0.0.0.0/0 0.0.0.0/0
fail2ban-regex /var/log/apache*/*error.log /etc/fail2ban/filter.d/apache-noscript.conf Shows

Quote:
Results
=======

Failregex
|- Regular expressions:
| [1] ^\[[^]]+\] \[error\] \[client <HOST>\] (File does not exist|script not found or unable to stat): /\S*(\.php|\.asp|\.exe|\.pl)\s*$
| [2] ^\[[^]]+\] \[error\] \[client <HOST>\] script '/\S*(\.php|\.asp|\.exe|\.pl)\S*' not found or unable to stat\s*$
|
`- Number of matches:
[1] 0 match(es)
[2] 77 match(es)

Ignoreregex
|- Regular expressions:
|
`- Number of matches:
 
Old 06-27-2014, 05:38 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Your jail is working.
Is 124.197.23.113 the only offending IP in /var/log/fail2ban.log?

try this in your apache-noscript jail:
Code:
[apache-noscript]

enabled = true
port = http,https
filter = apache-noscript
banaction	= apache-noscript
logpath = /var/log/apache*/*error.log
maxretry = 2
I'm using Fail2Ban v0.8.10 so you're not that far "behind" and 0.9.0 (2014/03/15) is the latest.

I also suggest using
Code:
loglevel = 3
in your /etc/fail2ban/fail2ban.conf to reduce the extraneous output in your /var/log/fail2ban.log such as all those DEBUGs.
You'll need to restart fail2ban for either or both edits. This will flush your iptables, so save them with
Code:
service iptables save
or
Code:
iptables-save > /path/to/saved.rules
What are the contents of /etc/fail2ban/filter.d/apache-noscript.conf ?

Edit:
Also what is the output of
Code:
ls -1 /etc/fail2ban/action.d/
#That's the number One

Thanks.

Last edited by Habitual; 06-27-2014 at 09:17 AM.
 
Old 06-30-2014, 01:08 AM   #7
ipv89
LQ Newbie
 
Registered: Jun 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
output of ls -1 /etc/fail2ban/action.d/

Quote:
complain.conf
dshield.conf
dummy.conf
hostsdeny.conf
ipfilter.conf
ipfw.conf
iptables-allports.conf
iptables-multiport-log.conf
iptables-multiport.conf
iptables-new.conf
iptables-xt_recent-echo.conf
iptables.conf
mail-buffered.conf
mail-whois-lines.conf
mail-whois.conf
mail.conf
mynetwatchman.conf
sendmail-buffered.conf
sendmail-whois-lines.conf
sendmail-whois.conf
sendmail.conf
shorewall.conf
I tried to restart after making the changes but I am receiving the an error
* Restarting authentication failure monitor fail2ban Fail

Output of log

Quote:
2014-06-30 01:04:20,545 fail2ban.filter : DEBUG Processing line with time:1404108258.0 and ip:124.197.23.113
2014-06-30 01:04:20,545 fail2ban.filter : DEBUG Found 124.197.23.113
2014-06-30 01:04:20,545 fail2ban.filter : DEBUG Currently have failures from 1 IPs: [u'124.197.23.113']
2014-06-30 01:04:20,546 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-30 01:04:20,643 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-30 01:04:20,643 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-30 01:04:20,644 fail2ban.filter.datedetector: DEBUG Sorting the template list
2014-06-30 01:04:20,754 fail2ban.filter : DEBUG Got event: 1 for /var/log/apache2/error.log
2014-06-30 01:04:20,754 fail2ban.filter : DEBUG File changed: /var/log/apache2/error.log
2014-06-30 01:04:20,755 fail2ban.filter.datedetector: DEBUG Sorting the template list
Thanks again for you help
 
Old 06-30-2014, 06:39 AM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
OK, then.
banaction = apache-noscript

Won't work as it does not exist.

make it
Code:
banaction	= iptables-multiport
and restart fail2ban.

Please let me know.
 
Old 07-04-2014, 10:15 PM   #9
ipv89
LQ Newbie
 
Registered: Jun 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
OK, then.
banaction = apache-noscript

Won't work as it does not exist.

make it
Code:
banaction	= iptables-multiport
and restart fail2ban.

Please let me know.
I tried that it did not work. it looks like fail2ban is banning the ip but its still getting through. could it be an issue with iptables?
 
Old 07-05-2014, 08:35 AM   #10
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by ipv89 View Post
it did not work....could it be an issue with iptables?
You'll have to be a bit more descriptive than "didn't work".
The issue is NOT with iptables, I don't think.
But this is very curious
Code:
Currently have failures from 1 IPs: [u'124.197.23.113']
The curious is in red.
Code:
WARNING [apache-noscript] Unban 124.197.23.113
You can fix this in 2 ways, set a default "bantime = " in /etc/fail2ban/jail.local under the
[DEFAULT] stanza, and/or set an explicit one in the "[apache-noscript]" stanza

bantime is in seconds.
Under [DEFAULT] this value would be for any stanza that does not have an explicit "bantime =" declared in the jail.
And none of your jails appear to have "bantime =" in them, so [DEFAULT]

Also, DEBUG mode is unnecessary at this time.
Edit /etc/fail2ban/fail2ban.conf and set
Code:
loglevel = 3
Modify /etc/fail2ban/jail.local and use:
Code:
[apache-noscript]

enabled = true
port = http,https
filter = apache-noscript
banaction	= apache-noscript
logpath = /var/log/apache*/*error.log
bantime  = 31556926 ; 1 year in seconds
maxretry = 2
Code:
; 1 year in seconds
is a comment. You can leave it out or include it as you see it here.

Restart fail2ban
If that doesn't solve the issue, post the entirety of your /etc/fail2ban/jail.local file, sanitize any sensitive IPs, if necessary.
Let us know!

Last edited by Habitual; 07-05-2014 at 06:04 PM.
 
Old 07-06-2014, 12:37 AM   #11
ipv89
LQ Newbie
 
Registered: Jun 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
You'll have to be a bit more descriptive than "didn't work".
The issue is NOT with iptables, I don't think.
But this is very curious
Code:
Currently have failures from 1 IPs: [u'124.197.23.113']
The curious is in red.
Code:
WARNING [apache-noscript] Unban 124.197.23.113
You can fix this in 2 ways, set a default "bantime = " in /etc/fail2ban/jail.local under the
[DEFAULT] stanza, and/or set an explicit one in the "[apache-noscript]" stanza

bantime is in seconds.
Under [DEFAULT] this value would be for any stanza that does not have an explicit "bantime =" declared in the jail.
And none of your jails appear to have "bantime =" in them, so [DEFAULT]

Also, DEBUG mode is unnecessary at this time.
Edit /etc/fail2ban/fail2ban.conf and set
Code:
loglevel = 3
Modify /etc/fail2ban/jail.local and use:
Code:
[apache-noscript]

enabled = true
port = http,https
filter = apache-noscript
banaction	= apache-noscript
logpath = /var/log/apache*/*error.log
bantime  = 31556926 ; 1 year in seconds
maxretry = 2
Code:
; 1 year in seconds
is a comment. You can leave it out or include it as you see it here.

Restart fail2ban
If that doesn't solve the issue, post the entirety of your /etc/fail2ban/jail.local file, sanitize any sensitive IPs, if necessary.
Let us know!
Thank you

I have changed the bantime, logging was already at level 3. Restarted Fail2ban and I am still receiving the same message in the log "2014-07-06 00:32:40,434 fail2ban.actions: WARNING [apache-noscript] 124.197.23.113 already banned"

however this ip can still access the page. Here is my complete jail.conf
Quote:
# Fail2Ban configuration file.
#
# This file was composed for Debian systems from the original one
# provided now under /usr/share/doc/fail2ban/examples/jail.conf
# for additional examples.
#
# To avoid merges during upgrades DO NOT MODIFY THIS FILE
# and rather provide your changes in /etc/fail2ban/jail.local
#
# Author: Yaroslav O. Halchenko <debian@onerussian.com>
#
# $Revision$
#

# The DEFAULT allows a global definition of the options. They can be overridden
# in each jail afterwards.

[DEFAULT]

# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8
bantime = 31556926
maxretry = 3

# "backend" specifies the backend used to get files modification. Available
# options are "gamin", "polling" and "auto".
# yoh: For some reason Debian shipped python-gamin didn't work as expected
# This issue left ToDo, so polling is default backend for now
backend = auto

#
# Destination email address used solely for the interpolations in
# jail.{conf,local} configuration files.
destemail = root@localhost

#
# ACTIONS
#

# Default banning action (e.g. iptables, iptables-new,
# iptables-multiport, shorewall, etc) It is used to define
# action_* variables. Can be overridden globally or per
# section within jail.local file
banaction = iptables-multiport

# email action. Since 0.8.1 upstream fail2ban uses sendmail
# MTA for the mailing. Change mta configuration parameter to mail
# if you want to revert to conventional 'mail'.
mta = sendmail

# Default protocol
protocol = tcp

# Specify chain where jumps would need to be added in iptables-* actions
chain = INPUT

#
# Action shortcuts. To be used to define action parameter

# The simplest action to take: ban only
action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]

# ban & send an e-mail with whois report to the destemail.
action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s"]

# ban & send an e-mail with whois report and relevant log lines
# to the destemail.
action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s"]

# Choose default action. To change, just override value of 'action' with the
# interpolation to the chosen action shortcut (e.g. action_mw, action_mwl, etc) in jail.local
# globally (section [DEFAULT]) or per specific section
action = %(action_)s

#
# JAILS
#

# Next jails corresponds to the standard configuration in Fail2ban 0.6 which
# was shipped in Debian. Enable any defined here jail by including
#
# [SECTION_NAME]
# enabled = true

#
# in /etc/fail2ban/jail.local.
#
# Optionally you may override any other parameter (e.g. banaction,
# action, port, logpath, etc) in that section within jail.local

[ssh]

enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 6

[dropbear]

enabled = false
port = ssh
filter = sshd
logpath = /var/log/dropbear
maxretry = 6

# Generic filter for pam. Has to be used with action which bans all ports
# such as iptables-allports, shorewall
[pam-generic]

enabled = false
# pam-generic filter can be customized to monitor specific subset of 'tty's
filter = pam-generic
# port actually must be irrelevant but lets leave it all for some possible uses
port = all
banaction = iptables-allports
port = anyport
logpath = /var/log/auth.log
maxretry = 6

[xinetd-fail]

enabled = false
filter = xinetd-fail
port = all
banaction = iptables-multiport-log
logpath = /var/log/daemon.log
maxretry = 2


[ssh-ddos]

enabled = false
port = ssh
filter = sshd-ddos
logpath = /var/log/auth.log
maxretry = 6

#
# HTTP servers
#

[apache]

enabled = true
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 2
action = iptables[name=apache-auth, port=80, protocol=tcp]


# default action is now multiport, so apache-multiport jail was left
# for compatibility with previous (<0.7.6-2) releases
[apache-multiport]
enabled = true
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 2
action = hostsdeny[name=fail2ban, port=80, protocol=tcp]

#[apache-phpmyadmin]
#enabled = true
#port = http,https
#filter = apache-phpmyadmin
#logpath = /var/log/apache*/*error.log
#maxretry = 3

[apache-noscript]

enabled = true
port = http,https
filter = apache-noscript
action = hostsdeny[name=fail2ban, port=80, protocol=tcp]
banaction = iptables-new
logpath = /var/log/apache*/*error.log
bantime = 31556926
maxretry = 2

[apache-overflows]

enabled = false
port = http,https
filter = apache-overflows
logpath = /var/log/apache*/*error.log
maxretry = 2

#
# FTP servers
#

[vsftpd]

enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = vsftpd
logpath = /var/log/vsftpd.log
# or overwrite it in jails.local to be
# logpath = /var/log/auth.log
# if you want to rely on PAM failed login attempts
# vsftpd's failregex should match both of those formats
maxretry = 6


[proftpd]

enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = proftpd
logpath = /var/log/proftpd/proftpd.log
maxretry = 6


[pure-ftpd]

enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = pure-ftpd
logpath = /var/log/auth.log
maxretry = 6


[wuftpd]

enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = wuftpd
logpath = /var/log/auth.log
maxretry = 6


#
# Mail servers
#

[postfix]

enabled = false
port = smtp,ssmtp
filter = postfix
logpath = /var/log/mail.log


[couriersmtp]

enabled = false
port = smtp,ssmtp
filter = couriersmtp
logpath = /var/log/mail.log


#
# Mail servers authenticators: might be used for smtp,ftp,imap servers, so
# all relevant ports get banned
#

[courierauth]

enabled = false
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter = courierlogin
logpath = /var/log/mail.log


[sasl]

enabled = false
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter = sasl
# You might consider monitoring /var/log/mail.warn instead if you are
# running postfix since it would provide the same log lines at the
# "warn" level but overall at the smaller filesize.
logpath = /var/log/mail.log

[dovecot]

enabled = false
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter = dovecot
logpath = /var/log/mail.log

# DNS Servers


# These jails block attacks against named (bind9). By default, logging is off
# with bind9 installation. You will need something like this:
#
# logging {
# channel security_file {
# file "/var/log/named/security.log" versions 3 size 30m;
# severity dynamic;
# print-time yes;
# };
# category security {
# security_file;
# };
# };
#
# in your named.conf to provide proper logging

# !!! WARNING !!!
# Since UDP is connection-less protocol, spoofing of IP and imitation
# of illegal actions is way too simple. Thus enabling of this filter
# might provide an easy way for implementing a DoS against a chosen
# victim. See
# http://nion.modprobe.de/blog/archive...-dns-fail.html
# Please DO NOT USE this jail unless you know what you are doing.
#[named-refused-udp]
#
#enabled = false
#port = domain,953
#protocol = udp
#filter = named-refused
#logpath = /var/log/named/security.log

[named-refused-tcp]

enabled = false
port = domain,953
protocol = tcp
filter = named-refused
logpath = /var/log/named/security.log


---------- Post added 07-06-14 at 12:37 AM ----------

Thanks again for your help
 
Old 07-06-2014, 09:39 AM   #12
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
What's in /usr/share/doc/fail2ban/examples/jail.conf?

You installed this, how?
Package Manager (apt-get), or from source?
If from a package manager, any reason you could not remove that and install from a source file download and start over?

There's some stuff you posted in your jail.conf that is not in the source file download, eg:

Code:
# ban & send an e-mail with whois report to the destemail.
action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s"]

# ban & send an e-mail with whois report and relevant log lines
# to the destemail.
action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s"]

Last edited by Habitual; 07-06-2014 at 09:42 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
IP Tables Help SilkySmooth Linux - Security 5 03-18-2012 03:32 PM
LXer: Tables of Contents, Indexes and Other Special Tables in Scribus LXer Syndicated Linux News 0 05-13-2011 05:30 AM
IP Tables help muru Linux - Security 3 09-27-2005 11:39 PM
IP TABLES help chrisfirestar Linux - Networking 2 10-29-2003 12:24 PM
IP Tables - What are they? yorkshiresteve Linux - Security 3 07-08-2003 04:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 06:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration