Splitbrain DNS: Any tutorials for setting this up easily?

Great, thank you so very much. Yes I’ve been adding those records and configurations in npm in the meantime. This is exactly what I’ve been trying to achieve for so long and it really was just that simply.

I appreciate your time a lot, plus this helped me understand the basics a bit more.

Sorry, I was under the impression that you are using the public Adguard DNS and not a local DNS. Of course then you don’t need Pihole and can use AdGuard instead.

I’m also interested in doing this, and I’m curious how you would set up a split brain situation with Let’s Encrypt certificates, since I have a “.dev” TLD already registered.

The problem with using something like pihole.home.domain.dev is that browsers won’t connect to them without HTTPS because of HTTP Strict Transport Security (HSTS, RFC 6797).

So I also have a pihole instance running, and it can happily pass out DNS entries for local stuff, but as above, I’d need to get HTTPS certificates for everything local - which, with something like caddy is automatic (and what I use for publicly reachable endpoints), but how would you set things up so that some things aren’t publicly reachable?

Firewall and a second caddy instance so that no internet traffic can reach the secondary caddy interface, but it can still proxy local things for local machines with https? I can see that working for things that are ONLY local, but then, what about things that are reachable for both instances? Would that then need both the public proxy and the private one set up to proxy those connections?

Thanks!

You can grab a certificate using a dns challenge. The challenge doesn’t require you inputting dns records publically, and uses temporary TXT records to prove ownership of the domain. You will want to use an API key with your dns provider to automate the generation of the temporary TXT records.

You then use that certificate on your second caddy instance as usual, or just install it on your server locally (the easiest choice IMO).

Second that. @shadowimmage if you’re already comfortable using Caddy - it supports a DNS challenge (see Automatic HTTPS — Caddy Documentation).
For example, I’m using Cloudflare to manage DNS records, and there is a module in Caddy for it. See what other providers are supported, by looking for dns.providers in the list of caddy modules.

It took a bunch more work than I expected it to, but I did successfully get a second caddy instance running, with DNS challenge using my DNS provider’s API.

Brief walkthrough:

  1. set up a caddy instance - I used a Proxmox LXC
  2. Update and install caddy
  3. Find out that the plugin needed for caddy to do dns challenges means you have to compile your own caddy with go and a command called xcaddy
  4. faff around looking for where this is documented
  5. get caddy built with your needed DNS provider’s DNS API plugin
  6. create an api key at your dns provider
  7. set your caddyfile options with the api key and secret
  8. find out that you have to enable api access to your domain
  9. wait
  10. HTTPS works!

So in more detail:
Installing Caddy isn’t too hard. it’s very straightforward with ubuntu/debian relatives.
The concept of having to rebuild caddy with the needed plugin was a little annoying. I thought they’d have an architecture that would use a plugin code without recompiling, but that’s not it. You have to rebuild caddy with your required plugins enabled at build time, OR download a prebuilt version. I couldn’t figure out the download a prebuilt with Porkbun’s API, so I went through the steps of installing Go, Getting the xcaddy software, then building my own version, and then using docs from here Build from source — Caddy Documentation
Its a little janky, but making it through it and having it working now it’s fine. Just new-to-me kind of way of doing things.

The issue with API access to your domain is probably a porkbun thing no big deal, really. The error in the caddy log was fairly straightforward. Porkbun was telling caddy exactly the issue, and so that was easy to fix.

I actually needed to change PiHole’s Custom DNS to use a separate subdomain than my usual public things so that they don’t step on each other. This is a little in the weeds, but,

Say I want to load jellyfin locally: I would need to use the IP:port address, or my public address j.h.domain.dev. I tried setting up j.h.domain.dev for my pihole dns override, but my pc was still grabbing the public CNAME to my router’s DDNS. So I compromised with the subdomain being “i.domain.dev” for internal, and “h.domain.dev” being “home” but from an external perspective…

Perhaps with the dns challenge caddy setup, I could rejigger some things so that I don’t have to use 2 different subdomains and make sure things are all happy, but that’s still a work-in-progress over here.

But in summary, I now have internally-reachable services, with HTTPS and nice DNS names, without any of that traffic leaving my local network, since my firewall knows nothing about the new caddy instance and can’t pass any traffic to it anyway, but local machines have no issue finding it, and can successfully access services proxied by it. Excellent.

Thanks!

Maybe some DNS cache on your device?

Hunted down the issue. The DHCP’s DNS entries handed out to my router to my always-on-VPN VLAN inserts the DNS server IP for the VPN service ahead of my local DNS server IP, so my machine doesn’t check the PiHole DNS first, but will fall back to it. So I gotta figure out how to change that around… not sure how yet though.