Cant resolve caddy urls when connected using wireguard vpn.

The issue I am facing:

Hi, Im trying to have local urls accessible both on my local network and through a wireguard vpn when away using pihole as my dns. I have gotten everything working except for getting a dns response back on the vpn network.

When I try dig one of my own urls on the vpn I get:

dig pihole.dashboard.cerval

; <<>> DiG 9.20.26 <<>> pihole.dashboard.cerval
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 30476
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;pihole.dashboard.cerval.	IN	A

;; Query time: 74 msec
;; SERVER: 10.174.21.110#53(10.174.21.110) (UDP)
;; WHEN: Wed Aug 05 13:55:09 CEST 2026
;; MSG SIZE  rcvd: 41

and it should be something like this:

 dig pihole.dashboard.cerval

; <<>> DiG 9.20.26 <<>> pihole.dashboard.cerval
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32215
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;pihole.dashboard.cerval.	IN	A

;; ANSWER SECTION:
pihole.dashboard.cerval. 0	IN	A	192.168.68.2

;; Query time: 73 msec
;; SERVER: 192.168.68.2#53(192.168.68.2) (UDP)
;; WHEN: Wed Aug 05 14:27:24 CEST 2026
;; MSG SIZE  rcvd: 68

I just never get an answer back on when i'm connecting via the vpn.

System and setup details
Im using nixos as my linux distro. So the config might look a bit weird.
Here is my wireguard config. this equivalent to using wireguard quick:

  networking.wg-quick.interfaces = {
    wg0 = {
      address = [ //addresses as in a normal configuration
        "fd88:dd88:88dd::1/64"
        "10.48.84.1/24"
      ];
      dns = [ "127.0.0.1" ];
      privateKeyFile = config.sops.secrets."wg0".path; //secrets manager
      listenPort = 50505; //listen port.

      postUp = ''
        ${pkgs.nftables}/bin/nft add table inet wg;
        ${pkgs.nftables}/bin/nft add chain inet wg wg_forward {type nat hook forward priority filter\; policy accept\;};
        ${pkgs.nftables}/bin/nft add chain inet wg wg_pre {type nat hook prerouting priority dstnat\; policy accept\;};
        ${pkgs.nftables}/bin/nft add chain inet wg wg_post {type nat hook postrouting priority srcnat\; policy accept\;};
        # forward wg0 traffic
	      ${pkgs.nftables}/bin/nft add rule inet wg wg_forward iifname wg0 accept;
        # masquerade for local ips
        ${pkgs.nftables}/bin/nft add rule inet wg wg_post counter packets 0 bytes 0 masquerade;
        # map other ip address for devices when away to avoid conflicts with other local networks and the home network.
        ${pkgs.nftables}/bin/nft add rule inet wg wg_pre iifname wg0 meta nfproto ipv4 ip daddr 10.44.88.0/24 dnat ip prefix to 192.168.2.0/24;
      '';

      postDown = ''
        ${pkgs.nftables}/bin/nft delete table inet wg;
      '';

      peers = [
	{
	  publicKey = "[pubkey]";
	  allowedIPs = [
	    "10.48.84.2/32"
      "fd88:dd88:88dd::2/128"
	  ];
	  persistentKeepalive = 25;
	}
  
[other peers here]

current as of now caddy config (again equivalent to a regular caddy config file):

  services.caddy = {
    enable = true;
    virtualHosts= {
      "pihole.dashboard.cerval".extraConfig = ''
        bind 0.0.0.0 [::]
        reverse_proxy http://127.0.0.1:8082
      '';
      "git.forgejo.cerval".extraConfig = ''
        bind 0.0.0.0 [::]
        reverse_proxy http://192.168.2.109:3000
      '';
    };
  };

The pihole route works on lan but not over the vpn. Currently the git server doesnt resolve in any context. Could be a slightly different issue but not sure.

I was hoping by prerouting the vpn ip to the lan ip that the single local ip would be enough for forgejo but because this doesnt work on even the lan ip that there is another issue behind it.

Relevant extra info
I have added the relevant domains to the domain list:

| gateway | 192.168.2.1 |
|----|----|----|
| git.forgejo | 192.168.2.109 |
| homelab | 192.168.2.109 |
| pihole | 192.168.2.2 |
| pihole.dashboard | 192.168.2.2 |
| pihole.dashboard | 10.48.84.1 | 

I have also set the dns to accept all incoming requests. So that isnt the issue either.

All vpn clients allow 2 ip ranges 10.48.84.0/24 and 10.44.88.0/24.

The vpn clients use the pihole as their dns and that works.

ipv4 and ipv6 forwarding are enabled.

My networking knowledge is self taught so I have holes in some places. Any ideas how I could resolve this?

Thanks in advance.

I don't have any experience with your setup, but from what I know about each piece of software you are using the following things look weird to me :

Who is :

That IP Address seems completely unrelated to your network ?!

Why isn't this an actual DNS IP Address ?!

If you are running WireGuard on the same host as Pi-Hole then I would expect to see there 10.48.84.1 maybe even with /24 or /32 behind it.
If you are routing DNS then the 192.168.1.2 IP Address is more fitting.

I see some NFTables NAT Rules so things could go either way...?!

Another thing which is weird @ Caddy :

This is nice =>

But that doesn't work with your Pi-Hole Local DNS Records =>

Because they don't point at the IP Address of Caddy I am guessing ?!

And we also come back to the DNS Server IP Address issue again :

You can't reach that if the DNS config for WireGuard is wrong! :slight_smile:

/Just some pointers that will hopefully bring you on the right path to solve this... Good luck! :wink:

Hey thanks for the reply.

that random ip-address in ur first quote is funnily enough points to the A root server. I traced it back, anyways i dont entirely understand what you mean by that caddy doesnt point to the same ip addresses bc the localhost ip should automatically be translated to 192.168.68.2. Or im misunderstanding you. Bc locally atleast the pihole dns seems to work. The .cerval gets added on the end automatically. So they should be the same.

that tip about the vpn, dns. Ill give it a shot my thinking was that the vpn was hosted on the device so I could use the localhost ip but maybe it doesnt work that way.

I am 100% sure it doesn't : Your VPN Client will try to connect to itself for DNS Resolving !!

Let's tackle that issue first and see the changes it brings :slight_smile:

Ah I get the confusion that wg client isnt a remote client, thr client in my example is the client running on the pihole host connecting the devices together. Also I didnt post all the peers of that example either. My actual clients away from home look like this:

[Interface]
Address = 10.48.84.3/32
DNS = 10.48.84.1, 192.168.2.2
ListenPort = 50505
PrivateKey = <private key>                       
[Peer]
AllowedIPs = 10.48.84.0/24, 10.44.88.0/24
Endpoint = <ddns endpoint>
PublicKey = <public key>

hopefully this clarifies things. Thanks again.

Edit: also I tried ur suggestion anyways and it had no effect.

OK, then before we continue maybe you could show us a drawing of your network setup first ?

Right now I don't really have a clear picture of the whole setup and it's hard to suggest anything useful :slight_smile:

The A root server (a.root-servers.net) is 198.41.0.4.

If you would be referring to 10.174.21.110:
That isn't a root server - it is a private IP from the 10.0.0.0/8 range, i.e. something on your local network or on one of your VPNs.

What machine did you run that dig from?

Also, please upload a debug log and post just the token URL that is generated after the log is uploaded by running the following command from the Pi-hole host terminal:

sudo pihole -d

or if you run your Pi-hole as a Docker container:

docker exec -it <pihole-container-name-or-id> pihole -d

where you substitute <pihole-container-name-or-id> as required.

sure,

Here it is roughly:

not sure how to really depict it as the 2 vpn ips sort of overlap but the 10.48.84.x range has access to 10.44.88.x even though devices under the latter ip range dont have ips in the range of 10.48.84.x. Also the 2 routers there is a double port forward. I dont live alone so I needed to keep the ISP router for stuff like television, even though everything is connected on the inner network.

Hopefully this helps.

:sweat_smile: yeah ur right, I thought the tool labelled it as the ip for the root server as a but it was just showing me the url.

I ran it from my laptop using a mobile hotspot for testing the vpn. I checked, its the ip assigned by my phones dhcp server.

sure thing!
debug token:
https://tricorder.pi-hole.net/oXsvASr7/

That would suggest that your laptop was connected to your phone's hotspot, but not to your Wireguard network when you ran that dig.

Could you verify that your laptop it is indeed successfully connected to your Pi-hole machine via Wireguard and rerun your dig?

alright here you go:

dig pihole.dashboard.cerval

; <<>> DiG 9.20.26 <<>> pihole.dashboard.cerval
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 58306
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;pihole.dashboard.cerval.	IN	A

;; Query time: 74 msec
;; SERVER: 10.232.7.164#53(10.232.7.164) (UDP)
;; WHEN: Sun Aug 09 15:03:08 CEST 2026
;; MSG SIZE  rcvd: 41

and the relevant interface:

4: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether <MAC> brd ff:ff:ff:ff:ff:ff
    altname wlx744ca1da8eed
    inet '10.232.7.182/24' brd 10.232.7.255 scope global dynamic noprefixroute wlp4s0
       valid_lft 3488sec preferred_lft 3488sec
    inet6 fe80::f642:ebc5:118e:4d6d/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

Yeah it seems to use the phone dns. Maybe I need to set the default dns for the entire laptop but what's funny is that the filtering and such does still work. I can see it my logs. Its only the custom caddy urls where it refers to another dns server.

Edit: only custom urls over the vpn where it refers to another dns server, on the home lan this does as intended... mostly but it has a separate issues that ill first try and figure out before I ask for help.

It sounds like your VPN might be doing split-horizon/split-brain behavior if local names resolve, locally. That could imply that it is using its own configured DNS for out of network stuff. It may not even allow in network DNS, like I believe some routers do.

I believe the local resolution happens without the vpn in play. The vpn ip's only work when Im away from home. I tried adding the vpn ips to caddy along with the ips for the lan network but no dice.

But please correct me if im wrong.

What's the client registering in Pi-hole's Query Log for those entries?

Dont exactly know what you mean by registering but it shows for my laptop over the vpn using a hotspot blocked/unblocked on both A and AAAA ips. As I said that seems to work. I dont see any other types.

Edit: for clarity the ip I filtered for was 10.48.84.4 which is my laptops ipv4 assigned wg ip.

Edit edit: Whrn im on my home network it shows as 192.168.2.120 in the logs.