host_firewall: drop new connections that enter and leave through the default-route interface
This commit is contained in:
@@ -37,6 +37,8 @@ set {{ name }} {
|
||||
{% set scrapers = firewall.scrapers | default({}, true) %}
|
||||
{% set forward_guard = firewall.forward_guard | default({}, true) | dict2items | rejectattr('value', 'none') | list %}
|
||||
{% set routed_v6 = firewall.routed_v6 | default({}, true) | dict2items | rejectattr('value', 'none') | map(attribute='value') | unique | list %}
|
||||
{% set uplink_ifaces = firewall.uplinks | default({}, true) | dict2items | rejectattr('value', 'none') | map(attribute='value') | list %}
|
||||
{% set no_reflect = ((firewall.no_reflect | default({}, true) | dict2items | rejectattr('value', 'none') | map(attribute='value') | list) + ([ansible_default_ipv4.interface | default(none), ansible_default_ipv6.interface | default(none)] | select | list)) | unique | difference(uplink_ifaces) | list %}
|
||||
{% set blocklists = firewall.spamhaus or firewall.firehol %}
|
||||
{% macro port_values(map) -%}
|
||||
{{ map | default({}, true) | dict2items | rejectattr('value', 'none') | map(attribute='value') | map('string') | unique | join(' ') }}
|
||||
@@ -442,10 +444,16 @@ table inet host {
|
||||
ip6 saddr @geo_v6 accept
|
||||
{% endif %}
|
||||
}
|
||||
{% if forward_guard or blocklists or firewall.scanners or rl_forward or firewall.block_smtp_out or firewall.uplinks %}
|
||||
{% if forward_guard or blocklists or firewall.scanners or rl_forward or firewall.block_smtp_out or firewall.uplinks or no_reflect %}
|
||||
|
||||
chain forward {
|
||||
type filter hook forward priority filter; policy accept;
|
||||
{% if no_reflect %}
|
||||
|
||||
# A packet that arrives on the interface of the default route and would leave through it again is a foreign
|
||||
# destination the datacenter routed to this host: it is not forwarded, or the host acts as a reflector.
|
||||
iifname { "{{ no_reflect | join('", "') }}" } oifname { "{{ no_reflect | join('", "') }}" } ct state new counter drop
|
||||
{% endif %}
|
||||
{% if rl_forward %}
|
||||
|
||||
# Docker-published ports and port forwards arrive here after DNAT; pod and guest egress is not DNATed.
|
||||
|
||||
Reference in New Issue
Block a user