Difference between revisions of "Commands"

From Fail2ban
Jump to: navigation, search
(BASIC: release - adds flushlogs)
(0.9.0 release)
 
Line 6: Line 6:
  
 
  $ fail2ban-client -i
 
  $ fail2ban-client -i
 
 
  
  
Line 39: Line 37:
 
| '''Command''' || || '''Description'''
 
| '''Command''' || || '''Description'''
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set loglevel <LEVEL></tt></span> || || sets logging level to <LEVEL>. 0 is minimal, 4 is debug
+
| <span style="white-space:nowrap;"><tt>set loglevel <LEVEL></tt></span> || || sets logging level to <LEVEL>. Levels: CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG
 
|-
 
|-
 
| <span style="white-space:nowrap;"><tt>get loglevel</tt></span> || || gets the logging level
 
| <span style="white-space:nowrap;"><tt>get loglevel</tt></span> || || gets the logging level
Line 48: Line 46:
 
|-
 
|-
 
| <span style="white-space:nowrap;"><tt>flushlogs</tt></span> || || flushes the logtarget if a file and reopens it. For log rotation.
 
| <span style="white-space:nowrap;"><tt>flushlogs</tt></span> || || flushes the logtarget if a file and reopens it. For log rotation.
 +
|}
 +
 +
=== DATABASE ===
 +
 +
 +
 +
{|
 +
| '''Command''' || || '''Description'''
 +
|-
 +
| <span style="white-space:nowrap;"><tt>set dbfile <FILE></tt></span> || || set the location of fail2ban persistent datastore. Set to "None" to disable
 +
|-
 +
| <span style="white-space:nowrap;"><tt>get dbfile</tt></span> || || get the location of fail2ban persistent datastore
 +
|-
 +
| <span style="white-space:nowrap;"><tt>set dbpurgeage <SECONDS></tt></span> || || sets the max age in <SECONDS> that history of bans will be kept
 +
|-
 +
| <span style="white-space:nowrap;"><tt>get dbpurgeage</tt></span> || || gets the max age in seconds that history of bans will be kept
 
|}
 
|}
  
Line 79: Line 93:
 
| <span style="white-space:nowrap;"><tt>set <JAIL> delignoreip <IP></tt></span> || || removes <IP> from the ignore list of <JAIL>
 
| <span style="white-space:nowrap;"><tt>set <JAIL> delignoreip <IP></tt></span> || || removes <IP> from the ignore list of <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> addlogpath <FILE></tt></span> || || adds <FILE> to the monitoring list of <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> addlogpath <FILE> ['tail']</tt></span> || || adds <FILE> to the monitoring list of <JAIL>, optionally starting at the 'tail' of the file (default 'head').
 
|-
 
|-
 
| <span style="white-space:nowrap;"><tt>set <JAIL> dellogpath <FILE></tt></span> || || removes <FILE> from the monitoring list of <JAIL>
 
| <span style="white-space:nowrap;"><tt>set <JAIL> dellogpath <FILE></tt></span> || || removes <FILE> from the monitoring list of <JAIL>
 +
|-
 +
| <span style="white-space:nowrap;"><tt>set <JAIL> logencoding <ENCODING></tt></span> || || sets the <ENCODING> of the log files for <JAIL>
 +
|-
 +
| <span style="white-space:nowrap;"><tt>set <JAIL> addjournalmatch <MATCH></tt></span> || || adds <MATCH> to the journal filter of <JAIL>
 +
|-
 +
| <span style="white-space:nowrap;"><tt>set <JAIL> deljournalmatch <MATCH></tt></span> || || removes <MATCH> from the journal filter of <JAIL>
 
|-
 
|-
 
| <span style="white-space:nowrap;"><tt>set <JAIL> addfailregex <REGEX></tt></span> || || adds the regular expression <REGEX> which must match failures for <JAIL>
 
| <span style="white-space:nowrap;"><tt>set <JAIL> addfailregex <REGEX></tt></span> || || adds the regular expression <REGEX> which must match failures for <JAIL>
Line 96: Line 116:
 
|-
 
|-
 
| <span style="white-space:nowrap;"><tt>set <JAIL> bantime <TIME></tt></span> || || sets the number of seconds <TIME> a host will be banned for <JAIL>
 
| <span style="white-space:nowrap;"><tt>set <JAIL> bantime <TIME></tt></span> || || sets the number of seconds <TIME> a host will be banned for <JAIL>
 +
|-
 +
| <span style="white-space:nowrap;"><tt>set <JAIL> datepattern <PATTERN></tt></span> || || sets the <PATTERN> used to match date/times for <JAIL>
 
|-
 
|-
 
| <span style="white-space:nowrap;"><tt>set <JAIL> usedns <VALUE></tt></span> || || sets the usedns mode for <JAIL>
 
| <span style="white-space:nowrap;"><tt>set <JAIL> usedns <VALUE></tt></span> || || sets the usedns mode for <JAIL>
Line 105: Line 127:
 
| <span style="white-space:nowrap;"><tt>set <JAIL> maxretry <RETRY></tt></span> || || sets the number of failures <RETRY> before banning the host for <JAIL>
 
| <span style="white-space:nowrap;"><tt>set <JAIL> maxretry <RETRY></tt></span> || || sets the number of failures <RETRY> before banning the host for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> addaction <ACT></tt></span> || || adds a new action named <NAME> for <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> maxlines <LINES></tt></span> || || sets the number of <LINES> to buffer for regex search for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> delaction <ACT></tt></span> || || removes the action <NAME> from <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> addaction <ACT>[ <PYTHONFILE> <JSONKWARGS>]</tt></span> || || adds a new action named <NAME> for <JAIL>. Optionally for a Python based action, a <PYTHONFILE> and <JSONKWARGS> can be specified, else will be a Command Action
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> setcinfo <ACT> <KEY> <VALUE></tt></span> || || sets <VALUE> for <KEY> of the action <NAME> for <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> delaction <ACT></tt></span> || || removes the action <ACT> from <JAIL>
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> delcinfo <ACT> <KEY></tt></span> || || removes <KEY> for the action <NAME> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> actionstart <ACT> <CMD></tt></span> || || sets the start command <CMD> of the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> actionstop <ACT> <CMD></tt></span> || || sets the stop command <CMD> of the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> actioncheck <ACT> <CMD></tt></span> || || sets the check command <CMD> of the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> actionban <ACT> <CMD></tt></span> || || sets the ban command <CMD> of the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> actionunban <ACT> <CMD></tt></span> || || sets the unban command <CMD> of the action <ACT> for <JAIL>
+
 
|}
 
|}
  
=== JAIL INFORMATION ===
+
=== COMMAND ACTION CONFIGURATION ===
  
  
Line 131: Line 141:
 
| '''Command''' || || '''Description'''
 
| '''Command''' || || '''Description'''
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get <JAIL> logpath</tt></span> || || gets the list of the monitored files for <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> action <ACT> actionstart <CMD></tt></span> || || sets the start command <CMD> of the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get <JAIL> ignoreip</tt></span> || || gets the list of ignored IP addresses for <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> action <ACT> actionstop <CMD></tt></span> || || sets the stop command <CMD> of the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get <JAIL> ignorecommand</tt></span> || || gets ignorecommand of <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> action <ACT> actioncheck <CMD></tt></span> || || sets the check command <CMD> of the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get <JAIL> failregex</tt></span> || || gets the list of regular expressions which matches the failures for <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> action <ACT> actionban <CMD></tt></span> || || sets the ban command <CMD> of the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get <JAIL> ignoreregex</tt></span> || || gets the list of regular expressions which matches patterns to ignore for <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> action <ACT> actionunban <CMD></tt></span> || || sets the unban command <CMD> of the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get <JAIL> findtime</tt></span> || || gets the time for which the filter will look back for failures for <JAIL>
+
| <span style="white-space:nowrap;"><tt>set <JAIL> action <ACT> timeout <TIMEOUT></tt></span> || || sets <TIMEOUT> as the command timeout in seconds for the action <ACT> for <JAIL>
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> bantime</tt></span> || || gets the time a host is banned for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> usedns</tt></span> || || gets the usedns setting for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> maxretry</tt></span> || || gets the number of failures allowed for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> addaction</tt></span> || || gets the last action which has been added for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actionstart <ACT></tt></span> || || gets the start command for the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actionstop <ACT></tt></span> || || gets the stop command for the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actioncheck <ACT></tt></span> || || gets the check command for the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actionban <ACT></tt></span> || || gets the ban command for the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actionunban <ACT></tt></span> || || gets the unban command for the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> cinfo <ACT> <KEY></tt></span> || || gets the value for <KEY> for the action <ACT> for <JAIL>
+
 
|}
 
|}
  
=== LOGGING ===
+
=== GENERAL ACTION CONFIGURATION ===
  
  
Line 171: Line 161:
 
| '''Command''' || || '''Description'''
 
| '''Command''' || || '''Description'''
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set loglevel <LEVEL></tt></span> || || sets logging level to <LEVEL>. 0 is minimal, 4 is debug
+
| <span style="white-space:nowrap;"><tt>set <JAIL> action <ACT> <PROPERTY> <VALUE></tt></span> || || sets the <VALUE> of <PROPERTY> for the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get loglevel</tt></span> || || gets the logging level
+
| <span style="white-space:nowrap;"><tt>set <JAIL> action <ACT> <METHOD>[ <JSONKWARGS>]</tt></span> || || calls the <METHOD> with <JSONKWARGS> for the action <ACT> for <JAIL>
|-
+
| <span style="white-space:nowrap;"><tt>set logtarget <TARGET></tt></span> || || sets logging target to <TARGET>. Can be STDOUT, STDERR, SYSLOG or a file
+
|-
+
| <span style="white-space:nowrap;"><tt>get logtarget</tt></span> || || gets logging target
+
 
|}
 
|}
  
=== JAIL CONTROL ===
+
=== JAIL INFORMATION ===
  
  
Line 187: Line 173:
 
| '''Command''' || || '''Description'''
 
| '''Command''' || || '''Description'''
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>add <JAIL> <BACKEND></tt></span> || || creates <JAIL> using <BACKEND>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> logpath</tt></span> || || gets the list of the monitored files for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>start <JAIL></tt></span> || || starts the jail <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> logencoding</tt></span> || || gets the encoding of the log files for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>stop <JAIL></tt></span> || || stops the jail <JAIL>. The jail is removed
+
| <span style="white-space:nowrap;"><tt>get <JAIL> journalmatch</tt></span> || || gets the journal filter match for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>status <JAIL></tt></span> || || gets the current status of <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> ignoreip</tt></span> || || gets the list of ignored IP addresses for <JAIL>
|}
+
 
+
=== JAIL CONFIGURATION ===
+
 
+
 
+
 
+
{|
+
| '''Command''' || || '''Description'''
+
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> idle on|off</tt></span> || || sets the idle state of <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> ignorecommand</tt></span> || || gets ignorecommand of <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> addignoreip <IP></tt></span> || || adds <IP> to the ignore list of <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> failregex</tt></span> || || gets the list of regular expressions which matches the failures for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> delignoreip <IP></tt></span> || || removes <IP> from the ignore list of <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> ignoreregex</tt></span> || || gets the list of regular expressions which matches patterns to ignore for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> addlogpath <FILE></tt></span> || || adds <FILE> to the monitoring list of <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> findtime</tt></span> || || gets the time for which the filter will look back for failures for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> dellogpath <FILE></tt></span> || || removes <FILE> from the monitoring list of <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> bantime</tt></span> || || gets the time a host is banned for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> addfailregex <REGEX></tt></span> || || adds the regular expression <REGEX> which must match failures for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> datepattern</tt></span> || || gets the patern used to match date/times for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> delfailregex <INDEX></tt></span> || || removes the regular expression at <INDEX> for failregex
+
| <span style="white-space:nowrap;"><tt>get <JAIL> usedns</tt></span> || || gets the usedns setting for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> addignoreregex <REGEX></tt></span> || || adds the regular expression <REGEX> which should match pattern to exclude for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> maxretry</tt></span> || || gets the number of failures allowed for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> delignoreregex <INDEX></tt></span> || || removes the regular expression at <INDEX> for ignoreregex
+
| <span style="white-space:nowrap;"><tt>get <JAIL> maxlines</tt></span> || || gets the number of lines to buffer for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> findtime <TIME></tt></span> || || sets the number of seconds <TIME> for which the filter will look back for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actions</tt></span> || || gets a list of actions for <JAIL>
 +
|}
 +
 
 +
=== COMMAND ACTION INFORMATION ===
 +
 
 +
 
 +
 
 +
{|
 +
| '''Command''' || || '''Description'''
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> bantime <TIME></tt></span> || || sets the number of seconds <TIME> a host will be banned for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> action <ACT> actionstart</tt></span> || || gets the start command for the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> usedns <VALUE></tt></span> || || sets the usedns mode for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> action <ACT> actionstop</tt></span> || || gets the stop command for the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> banip <IP></tt></span> || || manually Ban <IP> for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> action <ACT> actioncheck</tt></span> || || gets the check command for the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> unbanip <IP></tt></span> || || manually Unban <IP> in <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> action <ACT> actionban</tt></span> || || gets the ban command for the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> maxretry <RETRY></tt></span> || || sets the number of failures <RETRY> before banning the host for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> action <ACT> actionunban</tt></span> || || gets the unban command for the action <ACT> for <JAIL>
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> addaction <ACT></tt></span> || || adds a new action named <NAME> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> delaction <ACT></tt></span> || || removes the action <NAME> from <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> setcinfo <ACT> <KEY> <VALUE></tt></span> || || sets <VALUE> for <KEY> of the action <NAME> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> delcinfo <ACT> <KEY></tt></span> || || removes <KEY> for the action <NAME> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> actionstart <ACT> <CMD></tt></span> || || sets the start command <CMD> of the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> actionstop <ACT> <CMD></tt></span> || || sets the stop command <CMD> of the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> actioncheck <ACT> <CMD></tt></span> || || sets the check command <CMD> of the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>set <JAIL> actionban <ACT> <CMD></tt></span> || || sets the ban command <CMD> of the action <ACT> for <JAIL>
+
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>set <JAIL> actionunban <ACT> <CMD></tt></span> || || sets the unban command <CMD> of the action <ACT> for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> action <ACT> timeout</tt></span> || || gets the command timeout in seconds for the action <ACT> for <JAIL>
 
|}
 
|}
  
=== JAIL INFORMATION ===
+
=== GENERAL ACTION INFORMATION ===
  
  
Line 259: Line 229:
 
| '''Command''' || || '''Description'''
 
| '''Command''' || || '''Description'''
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get <JAIL> logpath</tt></span> || || gets the list of the monitored files for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actionproperties <ACT></tt></span> || || gets a list of properties for the action <ACT> for <JAIL>
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> ignoreip</tt></span> || || gets the list of ignored IP addresses for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> failregex</tt></span> || || gets the list of regular expressions which matches the failures for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> ignoreregex</tt></span> || || gets the list of regular expressions which matches patterns to ignore for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> findtime</tt></span> || || gets the time for which the filter will look back for failures for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> bantime</tt></span> || || gets the time a host is banned for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> usedns</tt></span> || || gets the usedns setting for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> maxretry</tt></span> || || gets the number of failures allowed for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> addaction</tt></span> || || gets the last action which has been added for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actionstart <ACT></tt></span> || || gets the start command for the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actionstop <ACT></tt></span> || || gets the stop command for the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actioncheck <ACT></tt></span> || || gets the check command for the action <ACT> for <JAIL>
+
|-
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actionban <ACT></tt></span> || || gets the ban command for the action <ACT> for <JAIL>
+
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get <JAIL> actionunban <ACT></tt></span> || || gets the unban command for the action <ACT> for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> actionmethods <ACT></tt></span> || || gets a list of methods for the action <ACT> for <JAIL>
 
|-
 
|-
| <span style="white-space:nowrap;"><tt>get <JAIL> cinfo <ACT> <KEY></tt></span> || || gets the value for <KEY> for the action <ACT> for <JAIL>
+
| <span style="white-space:nowrap;"><tt>get <JAIL> action <ACT> <PROPERTY></tt></span> || || gets the value of <PROPERTY> for the action <ACT> for <JAIL>
 
|}
 
|}

Latest revision as of 01:53, 15 March 2014

The commands presented above can be executed using:

$ fail2ban-client <COMMAND>

or by typing them in the interactive console available with:

$ fail2ban-client -i


BASIC

Command Description
start starts the server and the jails
reload reloads the configuration
reload <JAIL> reloads the jail <JAIL>
stop stops all jails and terminate the server
status gets the current status of the server
ping tests if the server is alive
help return this output

LOGGING

Command Description
set loglevel <LEVEL> sets logging level to <LEVEL>. Levels: CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG
get loglevel gets the logging level
set logtarget <TARGET> sets logging target to <TARGET>. Can be STDOUT, STDERR, SYSLOG or a file
get logtarget gets logging target
flushlogs flushes the logtarget if a file and reopens it. For log rotation.

DATABASE

Command Description
set dbfile <FILE> set the location of fail2ban persistent datastore. Set to "None" to disable
get dbfile get the location of fail2ban persistent datastore
set dbpurgeage <SECONDS> sets the max age in <SECONDS> that history of bans will be kept
get dbpurgeage gets the max age in seconds that history of bans will be kept

JAIL CONTROL

Command Description
add <JAIL> <BACKEND> creates <JAIL> using <BACKEND>
start <JAIL> starts the jail <JAIL>
stop <JAIL> stops the jail <JAIL>. The jail is removed
status <JAIL> gets the current status of <JAIL>

JAIL CONFIGURATION

Command Description
off sets the idle state of <JAIL>
set <JAIL> addignoreip <IP> adds <IP> to the ignore list of <JAIL>
set <JAIL> delignoreip <IP> removes <IP> from the ignore list of <JAIL>
set <JAIL> addlogpath <FILE> ['tail'] adds <FILE> to the monitoring list of <JAIL>, optionally starting at the 'tail' of the file (default 'head').
set <JAIL> dellogpath <FILE> removes <FILE> from the monitoring list of <JAIL>
set <JAIL> logencoding <ENCODING> sets the <ENCODING> of the log files for <JAIL>
set <JAIL> addjournalmatch <MATCH> adds <MATCH> to the journal filter of <JAIL>
set <JAIL> deljournalmatch <MATCH> removes <MATCH> from the journal filter of <JAIL>
set <JAIL> addfailregex <REGEX> adds the regular expression <REGEX> which must match failures for <JAIL>
set <JAIL> delfailregex <INDEX> removes the regular expression at <INDEX> for failregex
set <JAIL> ignorecommand <VALUE> sets ignorecommand of <JAIL>
set <JAIL> addignoreregex <REGEX> adds the regular expression <REGEX> which should match pattern to exclude for <JAIL>
set <JAIL> delignoreregex <INDEX> removes the regular expression at <INDEX> for ignoreregex
set <JAIL> findtime sets the number of seconds <TIME> for which the filter will look back for <JAIL>
<tt>set <JAIL> bantime <TIME></tt> sets the number of seconds <TIME> a host will be banned for <JAIL>
<tt>set <JAIL> datepattern <PATTERN></tt> sets the <PATTERN> used to match date/times for <JAIL>
<tt>set <JAIL> usedns <VALUE></tt> sets the usedns mode for <JAIL>
<tt>set <JAIL> banip <IP></tt> manually Ban <IP> for <JAIL>
<tt>set <JAIL> unbanip <IP></tt> manually Unban <IP> in <JAIL>
<tt>set <JAIL> maxretry <RETRY></tt> sets the number of failures <RETRY> before banning the host for <JAIL>
<tt>set <JAIL> maxlines <LINES></tt> sets the number of <LINES> to buffer for regex search for <JAIL>
<tt>set <JAIL> addaction <ACT>[ <PYTHONFILE> <JSONKWARGS>]</tt> adds a new action named <NAME> for <JAIL>. Optionally for a Python based action, a <PYTHONFILE> and <JSONKWARGS> can be specified, else will be a Command Action
<tt>set <JAIL> delaction <ACT></tt> removes the action <ACT> from <JAIL>

COMMAND ACTION CONFIGURATION

Command Description
<tt>set <JAIL> action <ACT> actionstart <CMD></tt> sets the start command <CMD> of the action <ACT> for <JAIL>
<tt>set <JAIL> action <ACT> actionstop <CMD></tt> sets the stop command <CMD> of the action <ACT> for <JAIL>
<tt>set <JAIL> action <ACT> actioncheck <CMD></tt> sets the check command <CMD> of the action <ACT> for <JAIL>
<tt>set <JAIL> action <ACT> actionban <CMD></tt> sets the ban command <CMD> of the action <ACT> for <JAIL>
<tt>set <JAIL> action <ACT> actionunban <CMD></tt> sets the unban command <CMD> of the action <ACT> for <JAIL>
<tt>set <JAIL> action <ACT> timeout <TIMEOUT></tt> sets <TIMEOUT> as the command timeout in seconds for the action <ACT> for <JAIL>

GENERAL ACTION CONFIGURATION

Command Description
<tt>set <JAIL> action <ACT> <PROPERTY> <VALUE></tt> sets the <VALUE> of <PROPERTY> for the action <ACT> for <JAIL>
<tt>set <JAIL> action <ACT> <METHOD>[ <JSONKWARGS>]</tt> calls the <METHOD> with <JSONKWARGS> for the action <ACT> for <JAIL>

JAIL INFORMATION

Command Description
<tt>get <JAIL> logpath</tt> gets the list of the monitored files for <JAIL>
<tt>get <JAIL> logencoding</tt> gets the encoding of the log files for <JAIL>
<tt>get <JAIL> journalmatch</tt> gets the journal filter match for <JAIL>
<tt>get <JAIL> ignoreip</tt> gets the list of ignored IP addresses for <JAIL>
<tt>get <JAIL> ignorecommand</tt> gets ignorecommand of <JAIL>
<tt>get <JAIL> failregex</tt> gets the list of regular expressions which matches the failures for <JAIL>
<tt>get <JAIL> ignoreregex</tt> gets the list of regular expressions which matches patterns to ignore for <JAIL>
<tt>get <JAIL> findtime</tt> gets the time for which the filter will look back for failures for <JAIL>
<tt>get <JAIL> bantime</tt> gets the time a host is banned for <JAIL>
<tt>get <JAIL> datepattern</tt> gets the patern used to match date/times for <JAIL>
<tt>get <JAIL> usedns</tt> gets the usedns setting for <JAIL>
<tt>get <JAIL> maxretry</tt> gets the number of failures allowed for <JAIL>
<tt>get <JAIL> maxlines</tt> gets the number of lines to buffer for <JAIL>
<tt>get <JAIL> actions</tt> gets a list of actions for <JAIL>

COMMAND ACTION INFORMATION

Command Description
<tt>get <JAIL> action <ACT> actionstart</tt> gets the start command for the action <ACT> for <JAIL>
<tt>get <JAIL> action <ACT> actionstop</tt> gets the stop command for the action <ACT> for <JAIL>
<tt>get <JAIL> action <ACT> actioncheck</tt> gets the check command for the action <ACT> for <JAIL>
<tt>get <JAIL> action <ACT> actionban</tt> gets the ban command for the action <ACT> for <JAIL>
<tt>get <JAIL> action <ACT> actionunban</tt> gets the unban command for the action <ACT> for <JAIL>
<tt>get <JAIL> action <ACT> timeout</tt> gets the command timeout in seconds for the action <ACT> for <JAIL>

GENERAL ACTION INFORMATION

Command Description
<tt>get <JAIL> actionproperties <ACT></tt> gets a list of properties for the action <ACT> for <JAIL>
<tt>get <JAIL> actionmethods <ACT></tt> gets a list of methods for the action <ACT> for <JAIL>
<tt>get <JAIL> action <ACT> <PROPERTY></tt> gets the value of <PROPERTY> for the action <ACT> for <JAIL>