Skip to content

Commit

Permalink
allow to limit default-drop logs (anti ddos)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Sep 3, 2024
1 parent 43f9166 commit 3a5ae2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions defaults/main/1_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ defaults_nftables:
purge_orphaned: true # purge all unmanaged files from /etc/nftables.d/

log_drop_prefix: 'NFTables DROP'
log_drop_limit: # anti DDOS
enable: false
count: 100
log_group: '' # set to '0' for container workaround => send logs to local ulogd2 daemon
ext: 'nft' # extension used for nftables config-files

Expand Down
2 changes: 1 addition & 1 deletion templates/etc/nftables.d/table.nft.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ table {{ nft_table.type }} {{ nft_table_name }} {
counter comment "COUNT {{ nft_table_name }}-{{ chain_name }}{% if chain_main %}-{{ chain.policy }}{% endif %}"
{% endif %}
{% if chain_main and chain.log.drop and chain.policy == 'drop' %}
log prefix "{{ NFT_CONFIG.log_drop_prefix }} {{ nft_table_name }}-{% if chain.log.prefix %}{{ chain.log.prefix }}{% else %}{{ chain_name }}{% endif %} "
log prefix "{{ NFT_CONFIG.log_drop_prefix }} {{ nft_table_name }}-{% if chain.log.prefix %}{{ chain.log.prefix }}{% else %}{{ chain_name }}{% endif %} "{% if NFT_CONFIG.log_drop_limit.enable | bool %} limit rate {{ NFT_CONFIG.log_drop_limit.count }}/second{% endif +%}
{% endif %}
}

Expand Down

0 comments on commit 3a5ae2c

Please sign in to comment.