Advertisement
Guest User

jail.conf

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