host_firewall: drop new connections that enter and leave through the default-route interface
This commit is contained in:
@@ -126,6 +126,11 @@ firewall:
|
|||||||
# never routes foreign destinations back out of the uplink or into the mesh and other interfaces. The kernel routes the
|
# never routes foreign destinations back out of the uplink or into the mesh and other interfaces. The kernel routes the
|
||||||
# prefix of the guest bridge, so no address is listed. The guest firewalls decide about the ports. IPv4 stays DNAT only.
|
# prefix of the guest bridge, so no address is listed. The guest firewalls decide about the ports. IPv4 stays DNAT only.
|
||||||
routed_v6: {}
|
routed_v6: {}
|
||||||
|
# Interfaces (name -> interface) whose forwarded traffic must not leave through the interface it arrived on, added to the
|
||||||
|
# interfaces of the default routes (IPv4 and IPv6) that every host gets. New connections that would be reflected drop;
|
||||||
|
# forwarding hosts (Kubernetes with Cilium, Docker, routing peers) otherwise route packets for foreign destinations that
|
||||||
|
# the datacenter sends to them back out. An uplink (see above) is already covered and left out.
|
||||||
|
no_reflect: {}
|
||||||
# Reject outbound TCP 25; the mail group turns it off.
|
# Reject outbound TCP 25; the mail group turns it off.
|
||||||
block_smtp_out: true
|
block_smtp_out: true
|
||||||
# EU-27 plus CH, NO, GB, IS, LI (ipdeny country codes). Empty leaves the geo
|
# EU-27 plus CH, NO, GB, IS, LI (ipdeny country codes). Empty leaves the geo
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ set {{ name }} {
|
|||||||
{% set scrapers = firewall.scrapers | default({}, true) %}
|
{% set scrapers = firewall.scrapers | default({}, true) %}
|
||||||
{% set forward_guard = firewall.forward_guard | default({}, true) | dict2items | rejectattr('value', 'none') | list %}
|
{% 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 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 %}
|
{% set blocklists = firewall.spamhaus or firewall.firehol %}
|
||||||
{% macro port_values(map) -%}
|
{% macro port_values(map) -%}
|
||||||
{{ map | default({}, true) | dict2items | rejectattr('value', 'none') | map(attribute='value') | map('string') | unique | join(' ') }}
|
{{ 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
|
ip6 saddr @geo_v6 accept
|
||||||
{% endif %}
|
{% 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 {
|
chain forward {
|
||||||
type filter hook forward priority filter; policy accept;
|
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 %}
|
{% if rl_forward %}
|
||||||
|
|
||||||
# Docker-published ports and port forwards arrive here after DNAT; pod and guest egress is not DNATed.
|
# Docker-published ports and port forwards arrive here after DNAT; pod and guest egress is not DNATed.
|
||||||
|
|||||||
Reference in New Issue
Block a user