RedditPP Mascot

RedditPP

r/PFSENSE • … • u/weeklygamingrecap

Pfsense, Pi-Hole, Redirect only 1 VLAN DNS to Pi-Hole with KeepAlived IP

I'm almost there with this but I can't seem to figure out how to redirect DNS to Pi-hole when a client forces a custom DNS like 8.8.8.8 or 1.1.1.1. I only want to filter clients who connect to IOT VLAN

`Main networks:` `WAN - DHCP` `LAN - 192.168.1.0/24 -- No DNS filtering by pi-hole, no blocked ports, where trusted devices and servers live (aka pi-hole, NAS, etc).`

`VLAN_WORK - 192.168.100.0/24 -- No DNS filtering by pi-hole, no blocked ports, blocked from other VLANs, should go straight out to internet like it was directly connected.`

`VLAN_IOT - 192.168.107.0/24 -- DNS should always be filtered by pi-hole, blocked from other VLANs with some exceptions to specific IP and Ports on LAN for pass-thru traffic where needed.`

`Pi-hole's connected to LAN` `192.168.1.32` `192.168.1.33`

`KeepAlived Virtual IP - 192.168.1.35`

DHCP is setup on every interface. Only on VLAN\_IOT do I force DNS to 192.168.1.35

There's a few other VLANs that I have setup but don't currently use.

![img](swoqz3bhoihe1 "Main DNS set to Quad9 as failover per Quad9 wiki")

\-

![img](52j9jdmqoihe1 "DNS Resolver settings, Network Interfaces disabled on IOT VLAN and WAN")

\-

![img](l8bydypfqihe1 "2nd half of DNS Resolver, Outgoing disabled on IOT VLAN")

\-

![img](jubx5w2xqihe1 "NAT Rules, DNS Redirect at top")

\-

![img](pa9ss312rihe1 "NAT Redirect Rule")

`NAT Reflect Rule Options:` `Interface: VLAN_IOT` `Source: VLAN_IOT Subnets` `Destination: VLAN_IOT address` `Destination port range: DNS` `Redirect target IP: 192.168.1.35` `Redirect target port: DNS` `NAT reflection: Disable`

I've played around with this rule a ton, changing NAT reflection to it's different options, changing Source to \*. It either doesn't work or seems to cause issues on other VLANs for some reason. But glad to revisit if something is off.

![img](7fpdtbpyrihe1 "LAN Firewall rules, I added the anti-lockout firewall rule and I have a few IP's for some clients in an alias to never block just in case.")

\-

![img](ohvbojpatihe1 "VLAN_WORK Firewall rules, blocked access to admin firewall ports. Only rule is an Alias with every IP range except VLAN_WORK.")

![img](6wsn886rtihe1 "VLAN_IOT Rules, blocked access to admin firewall ports, NAT DNS rule, Block DNS and DNS over TLS. A few rules to allow access to bitwarden, plex and jellyfin. A Final rule to block traffic to all other IP ranges except VLAN_IOT.")

\- If a device on IOT\_VLAN get's DHCP, they connect and see the Pi-hole just fine. If I force them to have a DNS, 8.8.8.8 it just by passes the Pi-Hole.

![img](12qjbe3fxihe1 "Pi-hole DNS set to Quad9, respond only on interface enX0")

![img](pw0nm3wjxihe1 "Never forward non-FQDN A and AAAA queries, Never forward reverse lookups for private IP ranges, USE DNSSEC.")

\-

![img](w2xgzorrxihe1 "DHCP on 192.168.107.120 client, shows Pi-Hole blocking and if I load up an adtest it works.")

\-

![img](owi6iyghzihe1 "Forced 8.8.8.8, rebooted and deleted the old query log. ")

Sometimes I'll see a block here, like you can see above. If I load up the same adtest, everything gets through or most does, refresh the page and then it all will.

I can swap DHCP vs 8.8.8.8 and flush the dns to go back and forth without a reboot and it behaves the same. DHCP always blocks no matter how much I refresh, forced DNS will sometimes on first loading a page block something but after browsing or a refresh nothing is blocked.

Testing using Windows 10 and edge in both regular and incognito mode.

I also tried to take KeepAlived out of the mix and changed the firewall to point to only a single Pi-Hole and that did not seem to make a difference so I put everything back since I would like to be able to have failover on them.

Also confirmed nothing is going to the failover Pi-Hole query logs and they are staying on the master.

![img](um1ep5t02jhe1)

If I check the states for the NAT Rule it looks like it is working?

— 0