You might find the techniques used in Network-Aware Firewall useful. You can use firewall configuration to handle connections differently depending on whether you are connected to your home network or not. Or you can use the same techniquest to do other things, depending on network connection, like bringing up your VPN or not; modifying DNS or hosts file or not; etc.
Selfhosted
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.
Rules:
-
Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.
-
No spam posting.
-
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.
-
Don't duplicate the full text of your blog or github here. Just post the link for folks to click.
-
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
-
No trolling.
-
No low-effort posts. This is subjective and will largely be determined by the community member reports.
Resources:
- selfh.st Newsletter and index of selfhosted software and apps
- awesome-selfhosted software
- awesome-sysadmin resources
- Self-Hosted Podcast from Jupiter Broadcasting
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
Could you do a subdomain for internal? Using Nginx host base routing to get to the same port would let you have a valid cert for both service.lan.your.fqdn and service.your.fqdn.
Let's Encrypt wildcard certs for the *.lan.your.fqdn would simplify things.
Your DNA server could then resolve the lan fqdns to your internal network and the non-lan to your Internet exposed?
Yes that would work, but it feels a bit cumbersome to have 2 fqdns per service, which I would have to switch between using depending on on whether I'm local or not.
Yeah, in that case, I'd probably split my DNS duties. I started with internal resolution by having Pihole do hard coded DNS entries for internal systems, but my current setup seems to be much more resilient.
I have two PowerDNS servers (main and replica) with recursors to Open DNS internet servers and resolvers for my lab network. It plays very nicely with Terraform or (crucially lately) Kubernetes.
Going the split DNS way is doable but had other issues (android devices bypassing local DNS for example or DNS over HTTPS issues)
I set up my opnSense to redorect all internal traffic to the external IP on port 443 to my internal server ip.
Works fine, it's transparent, and doesn't mess with DNS.
And so when away do you just directly connect to the external IP and do port forwarding?
I have opnsense, and it was pretty easy. I use DNS overrides and a local reverse proxy. When I'm on the home network, the local dns overrides point to the local reverse proxy. When I'm outside the home, public DNS records point to my VPS, which reverse proxies the traffic to my home machine. This way I'm only hitting the VPS when I'm outside the home. Much more efficient.
I think Side of Burritos' youtube channel has a guide on how to set this up, but it's fairly straightforward.
My Setup:
OpenWRT Router: wireguard server, backup DNS
NAS: Main DNS Server - pihole, no wireguard
VPS: Client - Endpoint 10.1.99.0/24, 192.168.2.0/24
Phone: Client - Endpoint 0.0.0.0/0, ::/0
10.1.99.0 clients can talk to 192.168.2.0 clients and back and forth. The NAS can talk to anyone, anyone can talk to the NAS. Any new client can talk to anything.
They all use the NAS for DNS, so they all resolve hostnames and domain names.
why not dns on the router?
I didn't like the unbound/adblock gui on Openwrt. I like pihole more. Personal pref.
I too run a PiHole in an RPi, physically plugged in to my OpenWRT router
There are Wireguard clients that connect based on wifi / mobile status. On f-droid WG Tunnel, WG Auto Connect, or Rethink should do.
Right but I want to be connected to wireguard always, I just want the DNS/routing to be different based on home vs foreign network.
WG Tunnel. It does exactly this.
When I leave my WiFi, tunnel turns on. When I rejoin my WiFi, tunnel turns off.
Adguard home has a DNS rewrite function that you can use to rewrite local DNS queries.
I use it to rewrite my queries at home to point to the LAN IP. When I am out I get my public IP from normal resolvers.
So you have a public DNS record pointing to your home IP?
DNS server you use from your home network retuns 192.168.1.20 for your service hosted at jellyfin.Bob.org
The DNS server you hit when publically looks up jellyfin.Bob.org and gets the IP from the nameserver you have set with your domain registrar often just theirs and you set this to your home WAN ip.
You have to configure both. I use opentofu / terraform to configure both all from the CLI. Any software like DNS that has a bunch of implementations that doesn't have Open-Tofu support gets skipped and an alternative is found at this stage. You just can't beat config as code for this type of set up.
You can also use NAT reflection which will effectively reroute the connection from within your network to your external IP to work on your local network.
I started with reflection and ended up going to the multiple DNS servers as it felt cleaner and I already was running Adguard so why not.
Both adguard and pihlle have opentofu modules.
Rereading your post (heh): In your case I'd just always serve over the wireguard ip local or not. Why do you want to use the local IP vs wireguard? The overhead of wireguard is pretty low
Oh hm I didn't think about your last point, maybe it's not really an issue at all. I think I'm not 100% on how the wireguard networking works.
Suppose I tunnel all of my traffic through wireguard on the remote server. Say that while I am home, I request foo.local, which on the remote server DNS maps to a wireguard address corresponding to my home machine. The remote will return to me the wireguard address corresponding to the home machine, and then I will try and go to that wireguard address. Will the home router recognize that that wireguard address is local and not send it out to the remote server?
I just use Avahi to use a .local domain when at home. That way felt easier. Also, I have separate bookmarks for “heimdall” and “heimdall-away” on my phone.
I ran into a similar issue when visiting some family. Even though I was connected to home via VPN, my devices wouldn't pull servers by their IPs. Our networks were setup too similarly. I was able to fix it by editing my conf for the WG connection and added my static servers as allowed IPs. While still having to self host a server for accounting at work, we did a similar split setup so they would be able to use RDP to their desktops but all other traffic was ignored and handled locally. This forum post has pretty good, short explanation with some example config scenarios https://forum.mikrotik.com/t/wireguard-allowed-ips-unofficial-wireguard-documentation/156426
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
| Fewer Letters | More Letters |
|---|---|
| DNS | Domain Name Service/System |
| HTTP | Hypertext Transfer Protocol, the Web |
| HTTPS | HTTP over SSL |
| IP | Internet Protocol |
| NAS | Network-Attached Storage |
| NAT | Network Address Translation |
| PiHole | Network-wide ad-blocker (DNS sinkhole) |
| RPi | Raspberry Pi brand of SBC |
| SBC | Single-Board Computer |
| SSD | Solid State Drive mass storage |
| SSL | Secure Sockets Layer, for transparent encryption |
| VPN | Virtual Private Network |
| VPS | Virtual Private Server (opposed to shared hosting) |
[Thread #78 for this comm, first seen 9th Feb 2026, 22:20] [FAQ] [Full list] [Contact] [Source code]
@mrh
I did similar thing for my selfhosted vaulwarden with tailscale and their funnel. give the client apps my tailscale address and i can hit on lan or off as long as the device is in the tailnet....and well the server is up 😎
I think tailscale would work, though I'd ideally want to use something like headscale instead, but that's a bit of a logistical hastle for my setup. Do you know if pangolin can handle this as well?
Tailscale.