diff --git a/host_firewall/templates/host.nft.j2 b/host_firewall/templates/host.nft.j2 index ce5a79c..59b20de 100644 --- a/host_firewall/templates/host.nft.j2 +++ b/host_firewall/templates/host.nft.j2 @@ -516,13 +516,15 @@ table inet host { {% endif %} {% endfor %} {% if firewall.block_smtp_out %} +{% set smtp_oif = ('oifname { "' ~ (uplink_ifaces | join('", "')) ~ '" } ') if uplink_ifaces else '' %} # Pod, container and guest egress to tcp/25 is rejected like the host's own (chain output). Connections DNATed to - # a mail host (ct status dnat) and traffic inside the cluster ring (nodes, pods) pass. - ct status & dnat == 0 ip daddr != @cluster_v4 tcp dport 25 limit rate {{ firewall.log.out_rate }} log prefix "fw-out-reject: " - ct status & dnat == 0 ip daddr != @cluster_v4 tcp dport 25 reject with tcp reset - ct status & dnat == 0 ip6 daddr != @cluster_v6 tcp dport 25 limit rate {{ firewall.log.out_rate }} log prefix "fw-out-reject: " - ct status & dnat == 0 ip6 daddr != @cluster_v6 tcp dport 25 reject with tcp reset + # a mail host (ct status dnat) and traffic inside the cluster ring (nodes, pods) pass. With uplinks configured + # only packets leaving through one are egress: a scan forwarded from the uplink to a guest is not. + ct status & dnat == 0 {{ smtp_oif }}ip daddr != @cluster_v4 tcp dport 25 limit rate {{ firewall.log.out_rate }} log prefix "fw-out-reject: " + ct status & dnat == 0 {{ smtp_oif }}ip daddr != @cluster_v4 tcp dport 25 reject with tcp reset + ct status & dnat == 0 {{ smtp_oif }}ip6 daddr != @cluster_v6 tcp dport 25 limit rate {{ firewall.log.out_rate }} log prefix "fw-out-reject: " + ct status & dnat == 0 {{ smtp_oif }}ip6 daddr != @cluster_v6 tcp dport 25 reject with tcp reset {% endif %} {% if forward_policy != 'accept' %}