Hi!
I have a VPS server with a WireGuard server (10.0.0.254) and a Pihole server.
I have an OpenWrt travel router (24.10) that has a LAN of 192.168.8.0/24 and is a WireGuard client (10.0.0.21).
The WireGuard interface (named wgclient) has its DNS address set to 10.0.0.250 (this is the alias of the WireGuard server that hosts Pihole). The AllowedIPs are 0.0.0.0/0, so all travel router traffic goes through the VPN tunnel.
On the WireGuard server side, the AllowedIPs are 10.0.0.21/32 and 192.168.8.0/24, so the local network is accessible via the VPN.
In this configuration, the travel router's clients are visible on the internet with the VPS server address, and DNS queries are processed by Pihole on the VPS – this is OK.
Currently, in Pihole's logs, all travel router clients appear as a single client, represented as the travel router.
For Pihole to recognize clients individually, you need to configure conditional forwarding in Pihole (https://discourse.pi-hole.net/t/conditional-forwarding-how-does-it-work/36644/2). So, in Pihole, in the conditional forwarding settings, I set:
true,192.168.8.0/24,192.168.8.254,NITZ
In my other installation, which has an OpenWrt home router and a separate Raspberry Pi running Pihole on the same local network, the conditional forwarding feature solved this problem.
Unfortunately, implementing conditional forwarding in Pihole on the VPS server didn't result in the travel router's clients being recognized individually.
I believe this is because AllowedIPs = 0.0.0.0/0 on the travel router's wgclient interface is set, and all travel router traffic is NATed to the WireGuard interface address.
Detailed configuration of the travel router:
root@NITZ-ROUTER:~# cat /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 'fd04:f1ad:96e::/48'
option packet_steering '1'
config device
option name 'br-lan'
option type 'bridge'
option bridge_empty '1'
list ports 'eth1'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.8.254'
option netmask '255.255.255.0'
option defaultroute '0'
config interface 'wan'
option device 'eth0'
option proto 'dhcp'
config interface 'wan6'
option device 'eth0'
option proto 'dhcpv6'
option reqaddress 'try'
option reqprefix 'auto'
option norelease '1'
option disabled '1'
config interface 'wwan'
option proto 'dhcp'
config interface 'wgclient'
option proto 'wireguard'
option private_key '????????????????????????????'
list addresses '10.0.0.8/32'
option mtu '1380'
list dns '10.0.0.250'
config wireguard_wgclient
option description 'VPS'
option public_key ''????????????????????????????''
option preshared_key ''????????????????????????????''
list allowed_ips '0.0.0.0/0'
option endpoint_host '???????'
option endpoint_port '51820'
option route_allowed_ips '1'
option persistent_keepalive '25'
root@NITZ-ROUTER:~# cat /etc/config/dhcp
config dnsmasq
option domainneeded '1'
option localise_queries '1'
option rebind_protection '0'
option local '/NITZ/'
option domain 'NITZ'
option expandhosts '1'
option cachesize '1000'
option authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
option localservice '1'
option ednspacket_max '1200'
option strictorder '1'
option serversfile '/var/run/adblock-fast/dnsmasq.servers'
config dhcp 'lan'
option interface 'lan'
option start '1'
option limit '10'
option leasetime '1h'
option dhcpv4 'server'
list dhcp_option '6,10.0.0.250'
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'
option piofolder '/tmp/odhcpd-piofolder'
root@NITZ-ROUTER:~# cat /etc/config/firewall
config defaults
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option synflood_protect '1'
option flow_offloading '1'
option flow_offloading_hw '1'
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan'
config zone
option name 'wan'
option input 'DROP'
option output 'ACCEPT'
option forward 'DROP'
option masq '1'
option mtu_fix '1'
list network 'wan'
list network 'wan6'
list network 'wwan'
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 'wgclient'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
option mtu_fix '1'
list network 'wgclient'
config forwarding
option src 'lan'
option dest 'wgclient'
config forwarding
option src 'wgclient'
option dest 'lan'
config forwarding
option src 'wgclient'
option dest 'wan'
More importantly, it is worth noting that the LAN interface distributes DNS via DHCP option 6,10.0.0.250, so the travel router clients use this DNS (also checked with the DNS leak tool).
Am I right? If so, how can I resolve this? If I'm wrong, where is the configuration error and how can I correct it?