Now my firewall that is not configured correctly, and all traffic goes through the wg0 interface. I want given DNS in PBR to work through wg0. Please tell me how to configure firewall.
Then I'll try to set it up PBR myself.
My configs:
/etc/config/firewall
config defaults
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option synflood_protect '1'
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
option masq '1'
option mtu_fix '1'
list network 'lan'
config zone
option name 'wg0'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option mtu_fix '1'
list network 'wg0'
option masq '1'
config forwarding
option src 'lan'
option dest 'wg0'
config zone
option name 'wan'
list network 'wan'
list network 'wg0'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
config forwarding
option src 'lan'
option dest 'wan'
config include 'pbr'
option fw4_compatible '1'
option type 'script'
option path '/usr/share/pbr/firewall.include'
/etc/config/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 'fdc5:642c:723b::/48'
config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.0.2'
option netmask '255.255.255.0'
option delegate '0'
config device
option name 'eth1'
option ipv6 '0'
config interface 'wan'
option proto 'static'
option device 'eth1'
option ipaddr '192.168.0.3'
option netmask '255.255.255.0'
option gateway '192.168.0.1'
list dns '8.8.8.8'
option delegate '0'
config interface 'wg0'
option proto 'wireguard'
option private_key '*'
list addresses '*'
list dns '*'
config wireguard_wg0
option public_key '*'
option private_key '*'
option preshared_key '*'
option route_allowed_ips '1'
option persistent_keepalive '25'
list allowed_ips '0.0.0.0/0'
option endpoint_host '*'
option endpoint_port '*'
Method via allowedips does not work. Thus, all traffic will be redirected to the tunnel, I need DNS routing!
Maybe I'm not expressing myself correctly and you don't understand me? My task is extremely simple, I need to make routing through DNS, so that clients who used OpenWRT as a gateway could go to certain https sites through the tunnel. I am not a network engineer and do not have high knowledge of English, due to which the manual received from you does not show me a solution. Therefore, I ask for your help.
How many network adapters does OpenWRT need, and which one should be used as the gateway for clients? 192.168.0.2(br-lan) or 192.168.0.3(eth1)?
What firewall settings are required? Which adapter requires which setting.
What settings are required for peer?
Сhatgpt and similar tools do not provide the necessary answer.Unfortunately, I can't devote time to solving this problem without interruptions, and I forget some details, so I need your help. Thx!
Make a rule in the PBR app and under Remote address/Domains add your URL's of choice this is an example where the domains e.g. ipleak.net etc. are routed via my mullvad VPN:
Note that e.g. streaming services like Netflix etc. are using a multitude of domains and you have to get them all.
The pbr package can be configured to utilize dnsmasq’s nftsets support, which requires the dnsmasq-full package with nftsets support to be installed (see How to install dnsmasq-full). This significantly improves the start up time because dnsmasq resolves the domain names and adds them to the appropriate nftset in background. dnsmasq’s nftset also automatically adds third-level domains to the set: if domain.com is added to the policy, this policy will affect all *.domain.com subdomains. This also works for top-level domains (TLDs) as well, a policy targeting the at TLD for example, will affect all the *.at domains.
Please review the Footnotes/Known Issues section, specifically #5 and #7 and any other information in that section relevant to domain-based routing/DNS.