host_firewall: pass LAPI client flows from wt0 to the pod port with their own address
This commit is contained in:
@@ -34,6 +34,11 @@ firewall:
|
|||||||
ifaces: {}
|
ifaces: {}
|
||||||
v4: {}
|
v4: {}
|
||||||
v6: {}
|
v6: {}
|
||||||
|
# Hosts outside the ring that reach a NodePort service (CrowdSec LAPI) over wt0, and the port of its pods: Cilium
|
||||||
|
# translates the NodePort before netfilter, so the flows arrive as client -> pod:port.
|
||||||
|
lapi:
|
||||||
|
port: null
|
||||||
|
clients: {}
|
||||||
# IPv4 port forwards: name -> {daddr, to, tcp: ports, udp: ports}, ports as in
|
# IPv4 port forwards: name -> {daddr, to, tcp: ports, udp: ports}, ports as in
|
||||||
# the maps above. Forwarded traffic passes the forward hook, not input.
|
# the maps above. Forwarded traffic passes the forward hook, not input.
|
||||||
dnat: {}
|
dnat: {}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ set {{ name }} {
|
|||||||
{% set guest_match = 'iifname { "' ~ (guest_ifaces | join('", "')) ~ '" }' %}
|
{% set guest_match = 'iifname { "' ~ (guest_ifaces | join('", "')) ~ '" }' %}
|
||||||
{% set dnat = firewall.dnat | default({}, true) | dict2items | rejectattr('value', 'none') | map(attribute='value') | list %}
|
{% set dnat = firewall.dnat | default({}, true) | dict2items | rejectattr('value', 'none') | map(attribute='value') | list %}
|
||||||
{% set masquerade = firewall.masquerade | default({}, true) | dict2items | rejectattr('value', 'none') | map(attribute='value') | unique | list %}
|
{% set masquerade = firewall.masquerade | default({}, true) | dict2items | rejectattr('value', 'none') | map(attribute='value') | unique | list %}
|
||||||
|
{% set lapi = cluster.lapi | default({}, true) %}
|
||||||
|
{% set lapi_rule = list(lapi.clients) and lapi.port %}
|
||||||
{% 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 blocklists = firewall.spamhaus or firewall.firehol %}
|
{% set blocklists = firewall.spamhaus or firewall.firehol %}
|
||||||
@@ -91,6 +93,9 @@ table inet host {
|
|||||||
{{ addr_set('admin_v6', 'ipv6_addr', firewall.admin.v6) }}
|
{{ addr_set('admin_v6', 'ipv6_addr', firewall.admin.v6) }}
|
||||||
{{ addr_set('cluster_v4', 'ipv4_addr', cluster.v4) }}
|
{{ addr_set('cluster_v4', 'ipv4_addr', cluster.v4) }}
|
||||||
{{ addr_set('cluster_v6', 'ipv6_addr', cluster.v6) }}
|
{{ addr_set('cluster_v6', 'ipv6_addr', cluster.v6) }}
|
||||||
|
{% if lapi_rule %}
|
||||||
|
{{ addr_set('lapi_clients_v4', 'ipv4_addr', lapi.clients) }}
|
||||||
|
{% endif %}
|
||||||
{{ addr_set('scrapers_v4', 'ipv4_addr', scrapers.v4) }}
|
{{ addr_set('scrapers_v4', 'ipv4_addr', scrapers.v4) }}
|
||||||
{{ addr_set('scrapers_v6', 'ipv6_addr', scrapers.v6) }}
|
{{ addr_set('scrapers_v6', 'ipv6_addr', scrapers.v6) }}
|
||||||
{{ addr_list_set('rl_exempt_v4', 'ipv4_addr', exempt_v4) }}
|
{{ addr_list_set('rl_exempt_v4', 'ipv4_addr', exempt_v4) }}
|
||||||
@@ -132,10 +137,15 @@ table inet host {
|
|||||||
# the host stack (veth with legacy host routing). This chain runs right after. Flows from the cluster ring (pods,
|
# the host stack (veth with legacy host routing). This chain runs right after. Flows from the cluster ring (pods,
|
||||||
# node NetBird addresses) into the pod CIDR arriving on wt0 get mark 0x1bd20: not masqueraded, and accepted by the
|
# node NetBird addresses) into the pod CIDR arriving on wt0 get mark 0x1bd20: not masqueraded, and accepted by the
|
||||||
# NetBird forward filter, which drops forwarded wt0 traffic that no route group allows. Other pod to pod flows
|
# NetBird forward filter, which drops forwarded wt0 traffic that no route group allows. Other pod to pod flows
|
||||||
# lose their marks.
|
# lose their marks. The same mark lets the LAPI clients (@lapi_clients_v4) reach the pod port of the NodePort service
|
||||||
|
# with their own address: Cilium has translated the NodePort before this point, so NetBird would masquerade the flow
|
||||||
|
# to the cilium_host address and the network policy would see world.
|
||||||
chain pod_identity {
|
chain pod_identity {
|
||||||
type filter hook prerouting priority -140; policy accept;
|
type filter hook prerouting priority -140; policy accept;
|
||||||
iifname "wt0" ct state new ip saddr @cluster_v4 ip daddr {{ cluster.v4.pods }} meta mark set 0x0001bd20
|
iifname "wt0" ct state new ip saddr @cluster_v4 ip daddr {{ cluster.v4.pods }} meta mark set 0x0001bd20
|
||||||
|
{% if lapi_rule %}
|
||||||
|
iifname "wt0" ct state new ip saddr @lapi_clients_v4 ip daddr {{ cluster.v4.pods }} tcp dport {{ lapi.port }} meta mark set 0x0001bd20
|
||||||
|
{% endif %}
|
||||||
ct state new ip saddr {{ cluster.v4.pods }} ip daddr {{ cluster.v4.pods }} meta mark 0x0001bd21 meta mark set 0
|
ct state new ip saddr {{ cluster.v4.pods }} ip daddr {{ cluster.v4.pods }} meta mark 0x0001bd21 meta mark set 0
|
||||||
ct state new ip saddr {{ cluster.v4.pods }} ip daddr {{ cluster.v4.pods }} meta mark 0x0001bd22 meta mark set 0
|
ct state new ip saddr {{ cluster.v4.pods }} ip daddr {{ cluster.v4.pods }} meta mark 0x0001bd22 meta mark set 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user