@vegbrasil said in Handling DNS resolution when IPsec is down:
I manage to fix this problem with a better "option 3":
Unbound on the branch office forwards only the needed zones to the main office, while all other zones are being forwarded to public DNS servers (root or not).
Here's the complete step by step:
Make sure you have your preferred external DNS server set in System -> General Setup -> DNS Server Settings.
Run DNS Resolver on the remote pfSense box but for the "Outgoing" interface, make sure you use the "LAN" interface, not the WAN. This is needed so that the requests go across the tunnel.
Under the "Domain Overrides", enter the domains that you need to have resolved by the DNS at the main branch (i.e. ad.company.com) and the IP address of those DNS servers. You can also add the in-addr.arpa to those forwarding domains as well if reverse lookups are needed. If you have more than one server, duplicate the entry but change the DNS IP.
Change the DHCP server settings to used the LAN address of the pfSense box as their DNS servers.
In this case, when the tunnel drops, the only items that will fail to resolve will be the ones that specifically are forwarded to the main branch.
I have the same setup although instead of using LAN in the outgoing interfaces in unbound, I use localhost OR use both WAN and the IPsec interface (as I use Routed VTI). This works the same way as you did but I'm not sure if there's an advantage.