| 1 |
# Logging |
| 2 |
|
| 3 |
|
| 4 |
## counter |
| 5 |
|
| 6 |
Add byte and packet counter to rule. All traffic matching this rule will be |
| 7 |
counted. Counter can be named or anonymous. To name a counter add name after |
| 8 |
`counter`, for example `counter my_counter`. |
| 9 |
|
| 10 |
Example: |
| 11 |
|
| 12 |
``` |
| 13 |
localhost-public { |
| 14 |
# Add named counter to count all outgoing traffic |
| 15 |
counter outgoing_traffic continue -conntrack |
| 16 |
|
| 17 |
# Accept ssh and add anonymous counter for it |
| 18 |
ssh counter |
| 19 |
|
| 20 |
# Accept http + https and add named counter |
| 21 |
http counter web_traffic |
| 22 |
https counter web_traffic |
| 23 |
|
| 24 |
# Reject SMTP with named counter |
| 25 |
smtp reject counter smtp_blocked |
| 26 |
} |
| 27 |
``` |
| 28 |
|
| 29 |
Named counter values can be listed with `foomuuri counter list`. Anonymous |
| 30 |
counters can be listed with `foomuuri ruleset list`. |
| 31 |
|
| 32 |
|
| 33 |
## log |
| 34 |
|
| 35 |
Write log entry (journal / syslog) when traffic matches this rule. Optional |
| 36 |
log prefix can be added. Default prefix is `szone-dzone STATEMENT`, for example |
| 37 |
`localhost-public REJECT`. |
| 38 |
|
| 39 |
Following variables are supported in log prefix: |
| 40 |
|
| 41 |
* `$(szone)` |
| 42 |
* `$(dzone)` |
| 43 |
* `$(statement)` |
| 44 |
|
| 45 |
Additional text to default log prefix can be added with `log + " my text"`, |
| 46 |
resulting `localhost-public REJECT my text`. |
| 47 |
|
| 48 |
Example: |
| 49 |
|
| 50 |
``` |
| 51 |
public-localhost { |
| 52 |
# Drop and log ssh with default prefix "public-localhost DROP" |
| 53 |
ssh drop log |
| 54 |
|
| 55 |
# Drop and log http with custom prefix "incoming-http dropped" |
| 56 |
http drop log "incoming-http dropped" |
| 57 |
|
| 58 |
# Drop and log https with custom prefix with variables. This results to |
| 59 |
# prefix "public => localhost: DROP" |
| 60 |
https drop log "$(szone) => $(dzone): $(statement)" |
| 61 |
|
| 62 |
# Drop and log telnet with custom prefix "public-localhost DROP:telnet" |
| 63 |
telnet drop log + ":telnet" # no space included to get "DROP:telnet" |
| 64 |
|
| 65 |
# Drop and log ftp with custom prefix "public-localhost DROP ftp-is-disabled" |
| 66 |
ftp drop log + " ftp-is-disabled" # space is included here |
| 67 |
|
| 68 |
# Use default prefix "public-localhost DROP" |
| 69 |
drop log |
| 70 |
} |
| 71 |
``` |
| 72 |
|
| 73 |
Foomuuri will limit logging to [log_rate](../section/foomuuri.md) rate. |
| 74 |
Default value is to log first three entries per source IP and then one |
| 75 |
additional entry per second. |
| 76 |
|
| 77 |
|
| 78 |
## log_level |
| 79 |
|
| 80 |
This overrides global `foomuuri { log_level ... }` logging level for this |
| 81 |
single rule. |
| 82 |
|
| 83 |
Possible values are: |
| 84 |
|
| 85 |
* `level emerg` |
| 86 |
* `level alert` |
| 87 |
* `level crit` |
| 88 |
* `level err` |
| 89 |
* `level warn` |
| 90 |
* `level notice` |
| 91 |
* `level info` |
| 92 |
* `level debug` |
| 93 |
|
| 94 |
Optionally flags can be appended: |
| 95 |
|
| 96 |
* `flags tcp sequence,options` enables logging of TCP sequence and options |
| 97 |
* `flags ip options` enables IP options |
| 98 |
* `flags skuid` enables socket UID |
| 99 |
* `flags ether` enables ethernet link layer address |
| 100 |
* `flags all` enables all flags |
| 101 |
|
| 102 |
To use nflog infrastructure instead of syslog specify value `group 0` (or any |
| 103 |
other number) instead of `level x`. Nflog options can be appended: |
| 104 |
|
| 105 |
* `snaplen 256` specifies length of packet payload to include |
| 106 |
* `queue-threshold 20` will queue packets inside the kernel before sending |
| 107 |
them to userspace |
| 108 |
|
| 109 |
Example: |
| 110 |
|
| 111 |
``` |
| 112 |
public-localhost { |
| 113 |
# Drop and log incoming http requests with critical level, all flags |
| 114 |
http drop log log_level "level crit flags all" |
| 115 |
... |
| 116 |
} |
| 117 |
``` |