2022-12-20 19:47:11 +01:00
|
|
|
#!/usr/bin/env -S nft -f
|
|
|
|
|
|
|
|
table ip br0_ipv4 {
|
|
|
|
chain prerouting {
|
|
|
|
type nat hook prerouting priority -100;
|
|
|
|
{% for forward in vpn_bridge_dnat %}
|
2023-07-27 23:07:45 +02:00
|
|
|
iif {{ ansible_default_ipv4.interface }} tcp dport { {{ forward.ports | join(", ") }} } dnat to {{ forward.inet_address }};
|
2022-12-20 19:47:11 +01:00
|
|
|
{% endfor %}
|
|
|
|
}
|
|
|
|
|
2023-07-08 12:58:07 +02:00
|
|
|
chain forward {
|
|
|
|
type filter hook forward priority 0;
|
2023-07-27 23:07:45 +02:00
|
|
|
{% if local_inet_network is defined %}
|
2023-07-08 12:58:07 +02:00
|
|
|
|
2022-12-20 19:47:11 +01:00
|
|
|
ct state established,related accept;
|
2023-07-27 23:07:45 +02:00
|
|
|
iif br0 ip daddr {{ local_inet_network }} drop;
|
2022-12-20 19:47:11 +01:00
|
|
|
{% endif %}
|
2023-07-27 23:07:45 +02:00
|
|
|
{% if vpn_bridge_local_only_inet_daddr %}
|
2023-07-08 12:58:07 +02:00
|
|
|
|
2023-07-27 23:07:45 +02:00
|
|
|
# Drop all external traffic for these addresses.
|
|
|
|
ip saddr != {{ vpn_bridge_inet_subnet }} ip daddr { {{ vpn_bridge_local_only_inet_daddr | join(", ") }} } drop;
|
2023-07-08 12:58:07 +02:00
|
|
|
{% endif %}
|
|
|
|
}
|
2022-12-20 19:47:11 +01:00
|
|
|
}
|