Ok, I have put the PBR in place and I have added the wg0 back to lan fw zone.
I repost the config:
uci export network; \
> uci export pbr; uci export firewall; \
> ip -4 addr ; ip -4 ro li tab all ; ip -4 ru; \
> nft list ruleset
package network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fda0:c13f:ea34::/48'
config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option netmask '255.255.255.0'
option ip6assign '60'
option ipaddr '192.168.201.1'
config interface 'wan'
option device 'eth1'
option proto 'static'
option ipaddr '192.168.100.35'
option netmask '255.255.255.0'
option gateway '192.168.100.1'
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch0'
option vlan '1'
option ports '1 2 3 4 0'
config interface 'wg0'
option proto 'wireguard'
option private_key 'a'
option listen_port '51820'
list addresses '192.168.202.1/24'
config wireguard_wg0
option description 'px'
option public_key 'b'
option private_key 'c'
list allowed_ips '192.168.202.10/32'
option route_allowed_ips '1'
config wireguard_wg0
option public_key 'd'
option private_key 'e'
option description 't1'
option route_allowed_ips '1'
list allowed_ips '192.168.202.11/32'
config interface 'novpn'
option proto 'none'
option device 'tun0'
package pbr
config pbr 'config'
option verbosity '2'
option strict_enforcement '1'
option resolver_set 'none'
option ipv6_enabled '0'
list ignored_interface 'vpnserver'
list ignored_interface 'wgserver'
option boot_timeout '30'
option rule_create_option 'add'
option procd_reload_delay '1'
list webui_supported_protocol 'all'
list webui_supported_protocol 'tcp'
list webui_supported_protocol 'udp'
list webui_supported_protocol 'tcp udp'
list webui_supported_protocol 'icmp'
option enabled '1'
option resolver_ipset 'none'
option webui_show_ignore_target '1'
config include
option path '/usr/share/pbr/pbr.user.aws'
option enabled '0'
config include
option path '/usr/share/pbr/pbr.user.netflix'
option enabled '0'
config policy
option dest_addr '192.168.201.0/24 192.168.100.0/24'
option interface 'ignore'
option enabled '0'
config policy
option src_addr '192.168.100.0/24'
option interface 'novpn'
option enabled '0'
config policy
option name 'vpnspezial'
option src_port '51820'
option proto 'udp'
option chain 'output'
option interface 'wan'
package firewall
config defaults
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
option synflood_protect '1'
config zone 'lan'
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan'
list network 'wg0'
config zone 'wan'
option name 'wan'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option mtu_fix '1'
list network 'wan'
config forwarding
option src 'lan'
option dest 'wan'
config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'
config rule
option name 'Allow-Ping'
option src 'wan'
option proto 'icmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-IGMP'
option src 'wan'
option proto 'igmp'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-DHCPv6'
option src 'wan'
option proto 'udp'
option dest_port '546'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-MLD'
option src 'wan'
option proto 'icmp'
option src_ip 'fe80::/10'
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Input'
option src 'wan'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
list icmp_type 'router-solicitation'
list icmp_type 'neighbour-solicitation'
list icmp_type 'router-advertisement'
list icmp_type 'neighbour-advertisement'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Forward'
option src 'wan'
option dest '*'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-IPSec-ESP'
option src 'wan'
option dest 'lan'
option proto 'esp'
option target 'ACCEPT'
config rule
option name 'Allow-ISAKMP'
option src 'wan'
option dest 'lan'
option dest_port '500'
option proto 'udp'
option target 'ACCEPT'
config zone
option name 'Wireguard'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
config forwarding
option src 'Wireguard'
option dest 'lan'
config forwarding
option src 'wan'
option dest 'Wireguard'
config forwarding
option src 'Wireguard'
option dest 'wan'
config rule
option name 'wan-local-wireguard'
list proto 'udp'
option src 'wan'
option dest_port '51820'
option target 'ACCEPT'
config rule
option src 'Wireguard'
option dest 'wan'
option target 'ACCEPT'
option name 'wg to wan'
config zone
option name 'vpnfw'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
list network 'novpn'
config forwarding
option src 'lan'
option dest 'vpnfw'
config include 'pbr'
option fw4_compatible '1'
option type 'script'
option path '/usr/share/pbr/pbr.firewall.include'
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 192.168.100.35/24 brd 192.168.100.255 scope global eth1
valid_lft forever preferred_lft forever
6: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
inet 192.168.201.1/24 brd 192.168.201.255 scope global br-lan
valid_lft forever preferred_lft forever
7: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000
inet 192.168.202.1/24 brd 192.168.202.255 scope global wg0
valid_lft forever preferred_lft forever
12: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500
inet 10.8.0.6/24 scope global tun0
valid_lft forever preferred_lft forever
default via 192.168.100.1 dev eth1 table pbr_wan
192.168.201.0/24 dev br-lan table pbr_wan proto kernel scope link src 192.168.201.1
default via 192.168.202.1 dev wg0 table pbr_wg0
192.168.201.0/24 dev br-lan table pbr_wg0 proto kernel scope link src 192.168.201.1
default via 10.8.0.6 dev tun0 table pbr_novpn
192.168.201.0/24 dev br-lan table pbr_novpn proto kernel scope link src 192.168.201.1
0.0.0.0/1 via 10.8.0.1 dev tun0
default via 192.168.100.1 dev eth1 proto static
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.6
128.0.0.0/1 via 10.8.0.1 dev tun0
185.196.22.201 via 192.168.100.1 dev eth1
192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.35
192.168.201.0/24 dev br-lan proto kernel scope link src 192.168.201.1
192.168.202.0/24 dev wg0 proto kernel scope link src 192.168.202.1
192.168.202.10 dev wg0 proto static scope link
192.168.202.11 dev wg0 proto static scope link
broadcast 10.8.0.0 dev tun0 table local proto kernel scope link src 10.8.0.6
local 10.8.0.6 dev tun0 table local proto kernel scope host src 10.8.0.6
broadcast 10.8.0.255 dev tun0 table local proto kernel scope link src 10.8.0.6
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
broadcast 192.168.100.0 dev eth1 table local proto kernel scope link src 192.168.100.35
local 192.168.100.35 dev eth1 table local proto kernel scope host src 192.168.100.35
broadcast 192.168.100.255 dev eth1 table local proto kernel scope link src 192.168.100.35
broadcast 192.168.201.0 dev br-lan table local proto kernel scope link src 192.168.201.1
local 192.168.201.1 dev br-lan table local proto kernel scope host src 192.168.201.1
broadcast 192.168.201.255 dev br-lan table local proto kernel scope link src 192.168.201.1
broadcast 192.168.202.0 dev wg0 table local proto kernel scope link src 192.168.202.1
local 192.168.202.1 dev wg0 table local proto kernel scope host src 192.168.202.1
broadcast 192.168.202.255 dev wg0 table local proto kernel scope link src 192.168.202.1
0: from all lookup local
30000: from all fwmark 0x10000/0xff0000 lookup pbr_wan
30001: from all fwmark 0x20000/0xff0000 lookup pbr_wg0
30002: from all fwmark 0x30000/0xff0000 lookup pbr_novpn
32766: from all lookup main
32767: from all lookup default
table inet fw4 {
chain input {
type filter hook input priority filter; policy accept;
iifname "lo" accept comment "!fw4: Accept traffic from loopback"
ct state established,related accept comment "!fw4: Allow inbound established and related flows"
tcp flags syn / fin,syn,rst,ack jump syn_flood comment "!fw4: Rate limit TCP syn packets"
iifname { "wg0", "br-lan" } jump input_lan comment "!fw4: Handle lan IPv4/IPv6 input traffic"
iifname "eth1" jump input_wan comment "!fw4: Handle wan IPv4/IPv6 input traffic"
iifname "tun0" jump input_vpnfw comment "!fw4: Handle vpnfw IPv4/IPv6 input traffic"
}
chain forward {
type filter hook forward priority filter; policy drop;
ct state established,related accept comment "!fw4: Allow forwarded established and related flows"
iifname { "wg0", "br-lan" } jump forward_lan comment "!fw4: Handle lan IPv4/IPv6 forward traffic"
iifname "eth1" jump forward_wan comment "!fw4: Handle wan IPv4/IPv6 forward traffic"
iifname "tun0" jump forward_vpnfw comment "!fw4: Handle vpnfw IPv4/IPv6 forward traffic"
jump handle_reject
}
chain output {
type filter hook output priority filter; policy accept;
oifname "lo" accept comment "!fw4: Accept traffic towards loopback"
ct state established,related accept comment "!fw4: Allow outbound established and related flows"
oifname { "wg0", "br-lan" } jump output_lan comment "!fw4: Handle lan IPv4/IPv6 output traffic"
oifname "eth1" jump output_wan comment "!fw4: Handle wan IPv4/IPv6 output traffic"
oifname "tun0" jump output_vpnfw comment "!fw4: Handle vpnfw IPv4/IPv6 output traffic"
}
chain prerouting {
type filter hook prerouting priority filter; policy accept;
iifname { "wg0", "br-lan" } jump helper_lan comment "!fw4: Handle lan IPv4/IPv6 helper assignment"
iifname "eth1" jump helper_wan comment "!fw4: Handle wan IPv4/IPv6 helper assignment"
}
chain handle_reject {
meta l4proto tcp reject with tcp reset comment "!fw4: Reject TCP traffic"
reject comment "!fw4: Reject any other traffic"
}
chain syn_flood {
limit rate 25/second burst 50 packets return comment "!fw4: Accept SYN packets below rate-limit"
drop comment "!fw4: Drop excess packets"
}
chain input_lan {
jump accept_from_lan
}
chain output_lan {
jump accept_to_lan
}
chain forward_lan {
jump accept_to_wan comment "!fw4: Accept lan to wan forwarding"
jump accept_to_vpnfw comment "!fw4: Accept lan to vpnfw forwarding"
jump accept_to_lan
}
chain helper_lan {
}
chain accept_from_lan {
iifname { "wg0", "br-lan" } counter packets 173 bytes 13369 accept comment "!fw4: accept lan IPv4/IPv6 traffic"
}
chain accept_to_lan {
oifname { "wg0", "br-lan" } counter packets 1 bytes 160 accept comment "!fw4: accept lan IPv4/IPv6 traffic"
}
chain input_wan {
meta nfproto ipv4 udp dport 68 counter packets 0 bytes 0 accept comment "!fw4: Allow-DHCP-Renew"
icmp type echo-request counter packets 0 bytes 0 accept comment "!fw4: Allow-Ping"
meta nfproto ipv4 meta l4proto igmp counter packets 1 bytes 36 accept comment "!fw4: Allow-IGMP"
meta nfproto ipv6 udp dport 546 counter packets 0 bytes 0 accept comment "!fw4: Allow-DHCPv6"
ip6 saddr fe80::/10 icmpv6 type . icmpv6 code { mld-listener-query . no-route, mld-listener-report . no-route, mld-listener-done . no-route, mld2-listener-report . no-route } counter packets 0 bytes 0 accept comment "!fw4: Allow-MLD"
icmpv6 type { destination-unreachable, time-exceeded, echo-request, echo-reply, nd-router-solicit, nd-router-advert } limit rate 1000/second counter packets 1 bytes 168 accept comment "!fw4: Allow-ICMPv6-Input"
icmpv6 type . icmpv6 code { packet-too-big . no-route, parameter-problem . no-route, nd-neighbor-solicit . no-route, nd-neighbor-advert . no-route, parameter-problem . admin-prohibited } limit rate 1000/second counter packets 0 bytes 0 accept comment "!fw4: Allow-ICMPv6-Input"
udp dport 51820 counter packets 12 bytes 2112 accept comment "!fw4: wan-local-wireguard"
jump reject_from_wan
}
chain output_wan {
jump accept_to_wan
}
chain forward_wan {
icmpv6 type { destination-unreachable, time-exceeded, echo-request, echo-reply } limit rate 1000/second counter packets 0 bytes 0 accept comment "!fw4: Allow-ICMPv6-Forward"
icmpv6 type . icmpv6 code { packet-too-big . no-route, parameter-problem . no-route, parameter-problem . admin-prohibited } limit rate 1000/second counter packets 0 bytes 0 accept comment "!fw4: Allow-ICMPv6-Forward"
meta l4proto esp counter packets 0 bytes 0 jump accept_to_lan comment "!fw4: Allow-IPSec-ESP"
udp dport 500 counter packets 0 bytes 0 jump accept_to_lan comment "!fw4: Allow-ISAKMP"
jump accept_to_Wireguard comment "!fw4: Accept wan to Wireguard forwarding"
jump reject_to_wan
}
chain helper_wan {
}
chain accept_to_wan {
oifname "eth1" counter packets 0 bytes 0 accept comment "!fw4: accept wan IPv4/IPv6 traffic"
}
chain reject_from_wan {
iifname "eth1" counter packets 3 bytes 714 jump handle_reject comment "!fw4: reject wan IPv4/IPv6 traffic"
}
chain reject_to_wan {
oifname "eth1" counter packets 0 bytes 0 jump handle_reject comment "!fw4: reject wan IPv4/IPv6 traffic"
}
chain input_Wireguard {
jump accept_from_Wireguard
}
chain output_Wireguard {
jump accept_to_Wireguard
}
chain forward_Wireguard {
meta l4proto tcp counter packets 0 bytes 0 jump accept_to_wan comment "!fw4: wg to wan"
meta l4proto udp counter packets 0 bytes 0 jump accept_to_wan comment "!fw4: wg to wan"
jump accept_to_lan comment "!fw4: Accept Wireguard to lan forwarding"
jump accept_to_wan comment "!fw4: Accept Wireguard to wan forwarding"
jump reject_to_Wireguard
}
chain helper_Wireguard {
}
chain accept_from_Wireguard {
}
chain accept_to_Wireguard {
}
chain reject_to_Wireguard {
}
chain input_vpnfw {
jump reject_from_vpnfw
}
chain output_vpnfw {
jump accept_to_vpnfw
}
chain forward_vpnfw {
jump reject_to_vpnfw
}
chain accept_to_vpnfw {
oifname "tun0" counter packets 124 bytes 12509 accept comment "!fw4: accept vpnfw IPv4/IPv6 traffic"
}
chain reject_from_vpnfw {
iifname "tun0" counter packets 1 bytes 40 jump handle_reject comment "!fw4: reject vpnfw IPv4/IPv6 traffic"
}
chain reject_to_vpnfw {
oifname "tun0" counter packets 0 bytes 0 jump handle_reject comment "!fw4: reject vpnfw IPv4/IPv6 traffic"
}
chain dstnat {
type nat hook prerouting priority dstnat; policy accept;
}
chain srcnat {
type nat hook postrouting priority srcnat; policy accept;
oifname "tun0" jump srcnat_vpnfw comment "!fw4: Handle vpnfw IPv4/IPv6 srcnat traffic"
}
chain srcnat_vpnfw {
meta nfproto ipv4 masquerade comment "!fw4: Masquerade IPv4 vpnfw traffic"
}
chain raw_prerouting {
type filter hook prerouting priority raw; policy accept;
}
chain raw_output {
type filter hook output priority raw; policy accept;
}
chain mangle_prerouting {
type filter hook prerouting priority mangle; policy accept;
jump pbr_prerouting comment "Jump into pbr prerouting chain"
}
chain mangle_postrouting {
type filter hook postrouting priority mangle; policy accept;
jump pbr_postrouting comment "Jump into pbr postrouting chain"
}
chain mangle_input {
type filter hook input priority mangle; policy accept;
jump pbr_input comment "Jump into pbr input chain"
}
chain mangle_output {
type route hook output priority mangle; policy accept;
jump pbr_output comment "Jump into pbr output chain"
}
chain mangle_forward {
type filter hook forward priority mangle; policy accept;
iifname "eth1" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 ingress MTU fixing"
oifname "eth1" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 egress MTU fixing"
iifname "tun0" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone vpnfw IPv4/IPv6 ingress MTU fixing"
oifname "tun0" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone vpnfw IPv4/IPv6 egress MTU fixing"
jump pbr_forward comment "Jump into pbr forward chain"
}
chain pbr_forward {
}
chain pbr_input {
}
chain pbr_output {
udp sport 51820 goto pbr_mark_0x010000 comment "vpnspezial"
}
chain pbr_prerouting {
}
chain pbr_postrouting {
}
chain pbr_mark_0x010000 {
counter packets 12 bytes 1440 meta mark set meta mark & 0xff01ffff | 0x00010000
return
}
chain pbr_mark_0x020000 {
counter packets 0 bytes 0 meta mark set meta mark & 0xff02ffff | 0x00020000
return
}
chain pbr_mark_0x030000 {
counter packets 0 bytes 0 meta mark set meta mark & 0xff03ffff | 0x00030000
return
}
}