Help setting up Firewall/Network for OpenVPN & VLAN

Hi all, Hi @trendy

I'm sorry but I'm still struggling around this and can't get neither OpenVPN nor internet connection with routing running. I've seen meanwhile another thread Setting up a dedicated VPN VLAN - #12 by JDf with similar topic. I've tried to add according documentation https://openwrt.org/docs/guide-user/network/routing/examples/pbr_netifd#route_lan_to_vpn_with_failover_to_wan and also https://openwrt.org/docs/guide-user/services/vpn/openvpn/extras#network_interface but I don't know where to put hands on.

Thanks for your help and below the outputs (part 1/3):

root@OpenWrt:~# uci export network; uci export wireless; \
> uci export dhcp; uci export firewall; \
> head -n -0 /etc/firewall.user; \
> iptables-save -c; ip6tables-save -c; \
> ip -4 addr ; ip -4 ro li tab all ; ip -4 ru; \
> ip -6 addr ; ip -6 ro li tab all ; ip -6 ru; \
> ls -l  /etc/resolv.* /tmp/resolv.*; head -n -0 /etc/resolv.* /tmp/resolv.*
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 packet_steering '1'
	option ula_prefix 'fd3f:9d72:10b8::/48'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'lan1'
	list ports 'lan2'

config interface 'lan'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option device 'br-lan.99'
	option ip4table '1'
	option ip6table '1'

config interface 'wan'
	option device 'wan'
	option proto 'dhcp'

config interface 'wan6'
	option device 'wan'
	option proto 'dhcpv6'

config bridge-vlan
	option device 'br-lan'
	option vlan '3'
	list ports 'lan1:t'

config bridge-vlan
	option device 'br-lan'
	option vlan '4'
	list ports 'lan1:t'

config bridge-vlan
	option device 'br-lan'
	option vlan '99'
	list ports 'lan1:t'
	list ports 'lan2:u*'

config device
	option type 'bridge'
	option name 'br-iot'
	list ports 'br-lan.3'
	option bridge_empty '1'

config device
	option type 'bridge'
	option name 'br-guest'
	list ports 'br-lan.4'
	option bridge_empty '1'

config interface 'IOT'
	option proto 'static'
	option netmask '255.255.255.0'
	option device 'br-iot'
	option defaultroute '0'
	option ipaddr '10.214.30.1'

config interface 'GUEST'
	option proto 'static'
	option netmask '255.255.255.0'
	option defaultroute '0'
	option device 'br-guest'
	option ipaddr '172.19.40.1'

config bridge-vlan
	option device 'br-lan'
	option vlan '100'
	list ports 'lan1:t'

config interface 'HO'
	option proto 'static'
	option ipaddr '172.16.100.1'
	option netmask '255.255.255.0'
	option defaultroute '0'
	option device 'br-ho'

config device
	option type 'bridge'
	option name 'br-ho'
	list ports 'br-lan.100'
	option bridge_empty '1'

config interface 'vpn'
	option proto 'none'
	option device 'tun0'
	option ip4table '2'
	option ip6table '2'

config route 'vpn_rt'
	option interface 'vpn'
	option target '0.0.0.0/0'
	option onlink '1'

config rule 'lan_vpn'
	option in 'lan'
	option lookup '2'
	option priority '30000'

config rule6 'lan_vpn6'
	option in 'lan'
	option lookup '2'
	option priority '30000'

package wireless

config wifi-device 'radio0'
	option type 'mac80211'
	option channel '11'
	option hwmode '11g'
	option path '1e140000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0'
	option htmode 'HT20'
	option cell_density '0'
	option country 'CH'

config wifi-iface 'default_radio0'
	option device 'radio0'
	option network 'lan'
	option mode 'ap'
	option ssid 'OpenWrt'
	option encryption 'psk2'
	option key ‚xxxxxxxxxx‘
	option ieee80211r '1'
	option mobility_domain '123f'
	option ft_over_ds '0'
	option ft_psk_generate_local '1'

config wifi-device 'radio1'
	option type 'mac80211'
	option hwmode '11a'
	option path '1e140000.pcie/pci0000:00/0000:00:01.0/0000:02:00.0'
	option htmode 'VHT80'
	option cell_density '0'
	option country 'CH'
	option channel 'auto'

config wifi-iface 'default_radio1'
	option device 'radio1'
	option network 'lan'
	option mode 'ap'
	option ssid 'OpenWrt'
	option encryption 'psk2'
	option key 'xxxxxxxxxx'
	option ieee80211r '1'
	option mobility_domain '123f'
	option ft_over_ds '0'
	option ft_psk_generate_local '1'

package dhcp

config dnsmasq
	option domainneeded '1'
	option boguspriv '1'
	option filterwin2k '0'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option nonegcache '0'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
	option nonwildcard '1'
	option localservice '1'
	option ednspacket_max '1232'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv4 'server'
	option dhcpv6 'server'
	option ra 'server'
	list ra_flags 'managed-config'
	list ra_flags 'other-config'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'

config dhcp 'IOT'
	option interface 'IOT'
	option start '100'
	option limit '150'
	option leasetime '12h'
	list ra_flags 'none'

config dhcp 'GUEST'
	option interface 'GUEST'
	option start '100'
	option limit '150'
	option leasetime '12h'
	list ra_flags 'none'

config dhcp 'HO'
	option interface 'HO'
	option start '100'
	option limit '150'
	option leasetime '12h'
	list ra_flags 'none'

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 device 'tun+'
	list network 'lan'

config zone 'wan'
	option name 'wan'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option masq '1'
	option mtu_fix '1'
	list network 'wan'
	list network 'wan6'
	list network 'vpn'

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 src_ip 'fc00::/6'
	option dest_ip 'fc00::/6'
	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 rule
	option name 'Support-UDP-Traceroute'
	option src 'wan'
	option dest_port '33434:33689'
	option proto 'udp'
	option family 'ipv4'
	option target 'REJECT'
	option enabled '0'

config include
	option path '/etc/firewall.user'

config zone
	option name 'IOTzone'
	option output 'ACCEPT'
	option forward 'REJECT'
	option input 'ACCEPT'
	list network 'IOT'

config zone
	option name 'GUESTzone'
	option output 'ACCEPT'
	option forward 'REJECT'
	option input 'REJECT'
	list network 'GUEST'

config forwarding
	option src 'GUESTzone'
	option dest 'wan'

config forwarding
	option src 'lan'
	option dest 'IOTzone'

config zone
	option name 'HOzone'
	option output 'ACCEPT'
	option forward 'REJECT'
	option input 'ACCEPT'
	list network 'HO'

config forwarding
	option src 'HOzone'
	option dest 'wan'

config forwarding
	option src 'lan'
	option dest 'HOzone'

config rule
	option name 'Guest DHCP & DNS'
	option src 'GUESTzone'
	option dest_port '53 67 68'
	option target 'ACCEPT'

config rule 'ovpn'
	option name 'Allow-OpenVPN'
	option src 'wan'
	option dest_port '11945'
	option proto 'udp'
	option target 'ACCEPT'

# This file is interpreted as shell script.
# Put your custom iptables rules here, they will
# be executed with each firewall (re-)start.

# Internal uci firewall chains are flushed and recreated on reload, so
# put custom rules into the root chains e.g. INPUT or FORWARD or into the
# special user chains, e.g. input_wan_rule or postrouting_lan_rule.
# Generated by iptables-save v1.8.7 on Mon Aug  8 15:02:16 2022
*nat
:PREROUTING ACCEPT [28555:4732324]
:INPUT ACCEPT [2563:177561]
:OUTPUT ACCEPT [3434:232400]
:POSTROUTING ACCEPT [53:4376]
:postrouting_GUESTzone_rule - [0:0]
:postrouting_HOzone_rule - [0:0]
:postrouting_IOTzone_rule - [0:0]
:postrouting_lan_rule - [0:0]
:postrouting_rule - [0:0]
:postrouting_wan_rule - [0:0]
:prerouting_GUESTzone_rule - [0:0]
:prerouting_HOzone_rule - [0:0]
:prerouting_IOTzone_rule - [0:0]
:prerouting_lan_rule - [0:0]
:prerouting_rule - [0:0]
:prerouting_wan_rule - [0:0]
:zone_GUESTzone_postrouting - [0:0]
:zone_GUESTzone_prerouting - [0:0]
:zone_HOzone_postrouting - [0:0]
:zone_HOzone_prerouting - [0:0]
:zone_IOTzone_postrouting - [0:0]
:zone_IOTzone_prerouting - [0:0]
:zone_lan_postrouting - [0:0]
:zone_lan_prerouting - [0:0]
:zone_wan_postrouting - [0:0]
:zone_wan_prerouting - [0:0]
[28555:4732324] -A PREROUTING -m comment --comment "!fw3: Custom prerouting rule chain" -j prerouting_rule
[208:14147] -A PREROUTING -i tun+ -m comment --comment "!fw3" -j zone_lan_prerouting
[25382:4582582] -A PREROUTING -i br-lan.99 -m comment --comment "!fw3" -j zone_lan_prerouting
[2965:135595] -A PREROUTING -i wan -m comment --comment "!fw3" -j zone_wan_prerouting
[208:14147] -A PREROUTING -i tun0 -m comment --comment "!fw3" -j zone_wan_prerouting
[0:0] -A PREROUTING -i br-iot -m comment --comment "!fw3" -j zone_IOTzone_prerouting
[0:0] -A PREROUTING -i br-guest -m comment --comment "!fw3" -j zone_GUESTzone_prerouting
[0:0] -A PREROUTING -i br-ho -m comment --comment "!fw3" -j zone_HOzone_prerouting
[10557:1420799] -A POSTROUTING -m comment --comment "!fw3: Custom postrouting rule chain" -j postrouting_rule
[638:68851] -A POSTROUTING -o tun+ -m comment --comment "!fw3" -j zone_lan_postrouting
[5:1360] -A POSTROUTING -o br-lan.99 -m comment --comment "!fw3" -j zone_lan_postrouting
[9866:1347572] -A POSTROUTING -o wan -m comment --comment "!fw3" -j zone_wan_postrouting
[638:68851] -A POSTROUTING -o tun0 -m comment --comment "!fw3" -j zone_wan_postrouting
[0:0] -A POSTROUTING -o br-iot -m comment --comment "!fw3" -j zone_IOTzone_postrouting
[0:0] -A POSTROUTING -o br-guest -m comment --comment "!fw3" -j zone_GUESTzone_postrouting
[0:0] -A POSTROUTING -o br-ho -m comment --comment "!fw3" -j zone_HOzone_postrouting
[0:0] -A zone_GUESTzone_postrouting -m comment --comment "!fw3: Custom GUESTzone postrouting rule chain" -j postrouting_GUESTzone_rule
[0:0] -A zone_GUESTzone_prerouting -m comment --comment "!fw3: Custom GUESTzone prerouting rule chain" -j prerouting_GUESTzone_rule
[0:0] -A zone_HOzone_postrouting -m comment --comment "!fw3: Custom HOzone postrouting rule chain" -j postrouting_HOzone_rule
[0:0] -A zone_HOzone_prerouting -m comment --comment "!fw3: Custom HOzone prerouting rule chain" -j prerouting_HOzone_rule
[0:0] -A zone_IOTzone_postrouting -m comment --comment "!fw3: Custom IOTzone postrouting rule chain" -j postrouting_IOTzone_rule
[0:0] -A zone_IOTzone_prerouting -m comment --comment "!fw3: Custom IOTzone prerouting rule chain" -j prerouting_IOTzone_rule
[643:70211] -A zone_lan_postrouting -m comment --comment "!fw3: Custom lan postrouting rule chain" -j postrouting_lan_rule
[25590:4596729] -A zone_lan_prerouting -m comment --comment "!fw3: Custom lan prerouting rule chain" -j prerouting_lan_rule
[10504:1416423] -A zone_wan_postrouting -m comment --comment "!fw3: Custom wan postrouting rule chain" -j postrouting_wan_rule
[10504:1416423] -A zone_wan_postrouting -m comment --comment "!fw3" -j MASQUERADE
[3173:149742] -A zone_wan_prerouting -m comment --comment "!fw3: Custom wan prerouting rule chain" -j prerouting_wan_rule
COMMIT
# Completed on Mon Aug  8 15:02:16 2022
# Generated by iptables-save v1.8.7 on Mon Aug  8 15:02:16 2022
*mangle
:PREROUTING ACCEPT [435722:279684633]
:INPUT ACCEPT [17265:1677569]
:FORWARD ACCEPT [401881:274748866]
:OUTPUT ACCEPT [17631:3575319]
:POSTROUTING ACCEPT [419002:278298845]
[5134:312190] -A FORWARD -o wan -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: Zone wan MTU fixing" -j TCPMSS --clamp-mss-to-pmtu
[5574:330020] -A FORWARD -i wan -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: Zone wan MTU fixing" -j TCPMSS --clamp-mss-to-pmtu
[3312:202884] -A FORWARD -o tun0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: Zone wan MTU fixing" -j TCPMSS --clamp-mss-to-pmtu
[147:8820] -A FORWARD -i tun0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: Zone wan MTU fixing" -j TCPMSS --clamp-mss-to-pmtu
COMMIT