Advertisement
aka144

jail.local

Apr 11th, 2015
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.78 KB | None | 0 0
  1. This is my fail2ban jail.local file.
  2.  
  3. # Fail2Ban configuration file.
  4. #
  5. # This file was composed for Debian systems from the original one
  6. # provided now under /usr/share/doc/fail2ban/examples/jail.conf
  7. # for additional examples.
  8. #
  9. # Comments: use '#' for comment lines and ';' for inline comments
  10. #
  11. # To avoid merges during upgrades DO NOT MODIFY THIS FILE
  12. # and rather provide your changes in /etc/fail2ban/jail.local
  13. #
  14.  
  15. # The DEFAULT allows a global definition of the options. They can be overridden
  16. # in each jail afterwards.
  17.  
  18. [DEFAULT]
  19.  
  20. # "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not
  21. # ban a host which matches an address in this list. Several addresses can be
  22. # defined using space separator.
  23. ignoreip = 127.0.0.1/8
  24.  
  25. # "bantime" is the number of seconds that a host is banned.
  26. bantime = 7200
  27.  
  28. # A host is banned if it has generated "maxretry" during the last "findtime"
  29. # seconds.
  30. findtime = 600
  31. maxretry = 3
  32.  
  33. # "backend" specifies the backend used to get files modification.
  34. # Available options are "pyinotify", "gamin", "polling" and "auto".
  35. # This option can be overridden in each jail as well.
  36. #
  37. # pyinotify: requires pyinotify (a file alteration monitor) to be installed.
  38. # If pyinotify is not installed, Fail2ban will use auto.
  39. # gamin: requires Gamin (a file alteration monitor) to be installed.
  40. # If Gamin is not installed, Fail2ban will use auto.
  41. # polling: uses a polling algorithm which does not require external libraries.
  42. # auto: will try to use the following backends, in order:
  43. # pyinotify, gamin, polling.
  44. backend = auto
  45.  
  46. # "usedns" specifies if jails should trust hostnames in logs,
  47. # warn when reverse DNS lookups are performed, or ignore all hostnames in logs
  48. #
  49. # yes: if a hostname is encountered, a reverse DNS lookup will be performed.
  50. # warn: if a hostname is encountered, a reverse DNS lookup will be performed,
  51. # but it will be logged as a warning.
  52. # no: if a hostname is encountered, will not be used for banning,
  53. # but it will be logged as info.
  54. usedns = warn
  55.  
  56. #
  57. # Destination email address used solely for the interpolations in
  58. # jail.{conf,local} configuration files.
  59. destemail = mymaiaddress
  60.  
  61. #
  62. # Name of the sender for mta actions
  63. sendername = Fail2Ban
  64.  
  65. #
  66. # ACTIONS
  67. #
  68.  
  69. # Default banning action (e.g. iptables, iptables-new,
  70. # iptables-multiport, shorewall, etc) It is used to define
  71. # action_* variables. Can be overridden globally or per
  72. # section within jail.local file
  73. banaction = iptables-multiport
  74.  
  75. # email action. Since 0.8.1 upstream fail2ban uses sendmail
  76. # MTA for the mailing. Change mta configuration parameter to mail
  77. # if you want to revert to conventional 'mail'.
  78. mta = sendmail
  79.  
  80. # Default protocol
  81. protocol = all
  82.  
  83. # Specify chain where jumps would need to be added in iptables-* actions
  84. chain = INPUT
  85.  
  86. #
  87. # Action shortcuts. To be used to define action parameter
  88.  
  89. # The simplest action to take: ban only
  90. action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
  91.  
  92. # ban & send an e-mail with whois report to the destemail.
  93. action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
  94. %(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s", sendername="%(sendername)s"]
  95.  
  96. # ban & send an e-mail with whois report and relevant log lines
  97. # to the destemail.
  98. action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
  99. %(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s", sendername="%(sendername)s"]
  100.  
  101. # Choose default action. To change, just override value of 'action' with the
  102. # interpolation to the chosen action shortcut (e.g. action_mw, action_mwl, etc) in jail.local
  103. # globally (section [DEFAULT]) or per specific section
  104. action = %(action_mwl)s
  105.  
  106. #
  107. # JAILS
  108. #
  109.  
  110. # Next jails corresponds to the standard configuration in Fail2ban 0.6 which
  111. # was shipped in Debian. Enable any defined here jail by including
  112. #
  113. # [SECTION_NAME]
  114. # enabled = true
  115.  
  116. #
  117. # in /etc/fail2ban/jail.local.
  118. #
  119. # Optionally you may override any other parameter (e.g. banaction,
  120. # action, port, logpath, etc) in that section within jail.local
  121.  
  122. [ssh]
  123.  
  124. enabled = true
  125. port = 2200
  126. filter = sshd
  127. logpath = /var/log/auth.log
  128. maxretry = 6
  129.  
  130. [dropbear]
  131.  
  132. enabled = false
  133. port = ssh
  134. filter = dropbear
  135. logpath = /var/log/auth.log
  136. maxretry = 6
  137.  
  138. # Generic filter for pam. Has to be used with action which bans all ports
  139. # such as iptables-allports, shorewall
  140. [pam-generic]
  141.  
  142. enabled = false
  143. # pam-generic filter can be customized to monitor specific subset of 'tty's
  144. filter = pam-generic
  145. # port actually must be irrelevant but lets leave it all for some possible uses
  146. port = all
  147. banaction = iptables-allports
  148. port = anyport
  149. logpath = /var/log/auth.log
  150. maxretry = 6
  151.  
  152. [xinetd-fail]
  153.  
  154. enabled = false
  155. filter = xinetd-fail
  156. port = all
  157. banaction = iptables-multiport-log
  158. logpath = /var/log/daemon.log
  159. maxretry = 2
  160.  
  161.  
  162. [ssh-ddos]
  163.  
  164. enabled = true
  165. port = 2200
  166. filter = sshd-ddos
  167. logpath = /var/log/auth.log
  168. maxretry = 6
  169.  
  170.  
  171. # Here we use blackhole routes for not requiring any additional kernel support
  172. # to store large volumes of banned IPs
  173.  
  174. [ssh-route]
  175.  
  176. enabled = false
  177. filter = sshd
  178. action = route
  179. logpath = /var/log/sshd.log
  180. maxretry = 6
  181.  
  182. # Here we use a combination of Netfilter/Iptables and IPsets
  183. # for storing large volumes of banned IPs
  184. #
  185. # IPset comes in two versions. See ipset -V for which one to use
  186. # requires the ipset package and kernel support.
  187. [ssh-iptables-ipset4]
  188.  
  189. enabled = true
  190. port = 2200
  191. filter = sshd
  192. banaction = iptables-ipset-proto4
  193. logpath = /var/log/sshd.log
  194. maxretry = 6
  195.  
  196. [ssh-iptables-ipset6]
  197.  
  198. enabled = true
  199. port = 2200
  200. filter = sshd
  201. banaction = iptables-ipset-proto6
  202. logpath = /var/log/sshd.log
  203. maxretry = 6
  204.  
  205.  
  206. #
  207. # HTTP servers
  208. #
  209.  
  210. [apache]
  211.  
  212. enabled = false
  213. port = http,https
  214. filter = apache-auth
  215. logpath = /var/log/apache*/*error.log
  216. maxretry = 6
  217.  
  218. # default action is now multiport, so apache-multiport jail was left
  219. # for compatibility with previous (<0.7.6-2) releases
  220. [apache-multiport]
  221.  
  222. enabled = false
  223. port = http,https
  224. filter = apache-auth
  225. logpath = /var/log/apache*/*error.log
  226. maxretry = 6
  227.  
  228. [apache-noscript]
  229.  
  230. enabled = false
  231. port = http,https
  232. filter = apache-noscript
  233. logpath = /var/log/apache*/*error.log
  234. maxretry = 6
  235.  
  236. [apache-overflows]
  237.  
  238. enabled = false
  239. port = http,https
  240. filter = apache-overflows
  241. logpath = /var/log/apache*/*error.log
  242. maxretry = 2
  243.  
  244. # Ban attackers that try to use PHP's URL-fopen() functionality
  245. # through GET/POST variables. - Experimental, with more than a year
  246. # of usage in production environments.
  247.  
  248. [php-url-fopen]
  249.  
  250. enabled = true
  251. port = http,https
  252. filter = php-url-fopen
  253. logpath = /var/log/php-url-fopen.log
  254. maxretry = 1
  255.  
  256. # A simple PHP-fastcgi jail which works with lighttpd.
  257. # If you run a lighttpd server, then you probably will
  258. # find these kinds of messages in your error_log:
  259. # ALERT – tried to register forbidden variable ‘GLOBALS’
  260. # through GET variables (attacker '1.2.3.4', file '/var/www/default/htdocs/index.php')
  261.  
  262. [lighttpd-fastcgi]
  263.  
  264. enabled = false
  265. port = http,https
  266. filter = lighttpd-fastcgi
  267. logpath = /var/log/lighttpd/error.log
  268.  
  269. # Same as above for mod_auth
  270. # It catches wrong authentifications
  271.  
  272. [lighttpd-auth]
  273.  
  274. enabled = false
  275. port = http,https
  276. filter = suhosin
  277. logpath = /var/log/lighttpd/error.log
  278.  
  279. [nginx-http-auth]
  280.  
  281. enabled = true
  282. filter = nginx-http-auth
  283. port = http,https
  284. logpath = /var/log/nginx/error.log
  285.  
  286. # Monitor roundcube server
  287.  
  288. [roundcube-auth]
  289.  
  290. enabled = false
  291. filter = roundcube-auth
  292. port = http,https
  293. logpath = /var/log/roundcube/userlogins
  294.  
  295.  
  296. [sogo-auth]
  297.  
  298. enabled = false
  299. filter = sogo-auth
  300. port = http, https
  301. # without proxy this would be:
  302. # port = 20000
  303. logpath = /var/log/sogo/sogo.log
  304.  
  305.  
  306. #
  307. # FTP servers
  308. #
  309.  
  310. [vsftpd]
  311.  
  312. enabled = true
  313. port = ftp,ftp-data,ftps,ftps-data
  314. filter = vsftpd
  315. logpath = /var/log/vsftpd.log
  316. # or overwrite it in jails.local to be
  317. # logpath = /var/log/auth.log
  318. # if you want to rely on PAM failed login attempts
  319. # vsftpd's failregex should match both of those formats
  320. maxretry = 6
  321.  
  322.  
  323. [proftpd]
  324.  
  325. enabled = false
  326. port = ftp,ftp-data,ftps,ftps-data
  327. filter = proftpd
  328. logpath = /var/log/proftpd/proftpd.log
  329. maxretry = 6
  330.  
  331.  
  332. [pure-ftpd]
  333.  
  334. enabled = false
  335. port = ftp,ftp-data,ftps,ftps-data
  336. filter = pure-ftpd
  337. logpath = /var/log/syslog
  338. maxretry = 6
  339.  
  340.  
  341. [wuftpd]
  342.  
  343. enabled = false
  344. port = ftp,ftp-data,ftps,ftps-data
  345. filter = wuftpd
  346. logpath = /var/log/syslog
  347. maxretry = 6
  348.  
  349.  
  350. #
  351. # Mail servers
  352. #
  353.  
  354. [postfix]
  355.  
  356. enabled = true
  357. port = smtp,ssmtp,submission
  358. filter = postfix
  359. logpath = /var/log/mail.log
  360.  
  361.  
  362. [couriersmtp]
  363.  
  364. enabled = false
  365. port = smtp,ssmtp,submission
  366. filter = couriersmtp
  367. logpath = /var/log/mail.log
  368.  
  369.  
  370. #
  371. # Mail servers authenticators: might be used for smtp,ftp,imap servers, so
  372. # all relevant ports get banned
  373. #
  374.  
  375. [courierauth]
  376.  
  377. enabled = false
  378. port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
  379. filter = courierlogin
  380. logpath = /var/log/mail.log
  381.  
  382.  
  383. [sasl]
  384.  
  385. enabled = false
  386. port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
  387. filter = postfix-sasl
  388. # You might consider monitoring /var/log/mail.warn instead if you are
  389. # running postfix since it would provide the same log lines at the
  390. # "warn" level but overall at the smaller filesize.
  391. logpath = /var/log/mail.log
  392.  
  393. [dovecot]
  394.  
  395. enabled = false
  396. port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
  397. filter = dovecot
  398. logpath = /var/log/mail.log
  399.  
  400. # To log wrong MySQL access attempts add to /etc/my.cnf:
  401. # log-error=/var/log/mysqld.log
  402. # log-warning = 2
  403.  
  404. [mysqld-auth]
  405.  
  406. enabled = true
  407. filter = mysqld-auth
  408. port = 3306
  409. logpath = /var/log/mysqld.log
  410.  
  411.  
  412. # DNS Servers
  413.  
  414.  
  415. # These jails block attacks against named (bind9). By default, logging is off
  416. # with bind9 installation. You will need something like this:
  417. #
  418. # logging {
  419. # channel security_file {
  420. # file "/var/log/named/security.log" versions 3 size 30m;
  421. # severity dynamic;
  422. # print-time yes;
  423. # };
  424. # category security {
  425. # security_file;
  426. # };
  427. # };
  428. #
  429. # in your named.conf to provide proper logging
  430.  
  431. # !!! WARNING !!!
  432. # Since UDP is connection-less protocol, spoofing of IP and imitation
  433. # of illegal actions is way too simple. Thus enabling of this filter
  434. # might provide an easy way for implementing a DoS against a chosen
  435. # victim. See
  436. # http://nion.modprobe.de/blog/archives/690-fail2ban-+-dns-fail.html
  437. # Please DO NOT USE this jail unless you know what you are doing.
  438. #[named-refused-udp]
  439. #
  440. #enabled = false
  441. #port = domain,953
  442. #protocol = udp
  443. #filter = named-refused
  444. #logpath = /var/log/named/security.log
  445.  
  446. [named-refused-tcp]
  447.  
  448. enabled = false
  449. port = domain,953
  450. protocol = tcp
  451. filter = named-refused
  452. logpath = /var/log/named/security.log
  453.  
  454. # Multiple jails, 1 per protocol, are necessary ATM:
  455. # see https://github.com/fail2ban/fail2ban/issues/37
  456. [asterisk-tcp]
  457.  
  458. enabled = false
  459. filter = asterisk
  460. port = 5060,5061
  461. protocol = tcp
  462. logpath = /var/log/asterisk/messages
  463.  
  464. [asterisk-udp]
  465.  
  466. enabled = false
  467. filter = asterisk
  468. port = 5060,5061
  469. protocol = udp
  470. logpath = /var/log/asterisk/messages
  471.  
  472.  
  473. # Jail for more extended banning of persistent abusers
  474. # !!! WARNING !!!
  475. # Make sure that your loglevel specified in fail2ban.conf/.local
  476. # is not at DEBUG level -- which might then cause fail2ban to fall into
  477. # an infinite loop constantly feeding itself with non-informative lines
  478. [recidive]
  479.  
  480. enabled = false
  481. filter = recidive
  482. logpath = /var/log/fail2ban.log
  483. action = iptables-allports[name=recidive]
  484. sendmail-whois-lines[name=recidive, logpath=/var/log/fail2ban.log]
  485. bantime = 604800 ; 1 week
  486. findtime = 86400 ; 1 day
  487. maxretry = 5
  488.  
  489. [nginx-req-limit]
  490.  
  491. enabled = true
  492. filter = nginx-req-limit
  493. action = iptables-multiport[name=ReqLimit, port="http,https", protocol=tcp]
  494. logpath = /var/log/nginx/*error.log
  495. findtime = 600
  496. bantime = 7200
  497. maxretry = 10
  498.  
  499. [nginx-ratelimit]
  500. enabled = true
  501. port = http,https
  502. filter = nginx-ratelimit
  503. logpath = /var/log/nginx/error.log
  504. maxretry = 10
  505.  
  506. [wp-auth]
  507.  
  508. enabled = true
  509. filter = wp-auth
  510. port = http
  511. action = iptables[name=wp-auth, port=http, protocol=tcp]
  512. sendmail-whois[name=wp-auth, dest=mymaiaddress, sender=mymaiaddress]
  513. logpath = /var/log/nginx/access.log
  514. maxretry = 5
  515. bantime = 14400
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement