I have some subdomains that go to my home address (I know I should put it through a VPS first but I’ll get to that when I have time).

If I connect to example.domain.tld and DNS records point back to my own IP, where does that data go to reach back to my device?

Edit: thanks for the responses everyone

  • Darkassassin07@lemmy.ca
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    20 hours ago

    https://en.wikipedia.org/wiki/Network_address_translation#NAT_hairpinning

    TL;DR Your router sees you trying to reach your external address and routes the connection back to your LAN without leaving the network.

    This does still depend on a functional internet connection however, as your client gets your public IP from a public DNS server over the Internet.

    If you were to run a DNS server locally (I use pihole for this), you could have that DNS respond with your local IP, allowing clients within your LAN to resolve the name without needing to reach out to public DNS. This means your local connections will still work when your internet is down; it also provides more privacy by keeping those requests local and can let you make local-only names that aren’t publicly listed.

    Of the ~28 FQDNs in my setup, only 4 are public. The rest is local/vpn only and not publicly listed due the above. The reverse proxy then drops all connections that don’t use one of those recognised names, before even completing the TLS handshake. (So direct connections from someone port scanning my IP or using a domain name someone else has pointed at my IP are completely ignored/dropped without response. The server doesn’t even send the TLS cert so as to not expose the names defined in it.)