this post was submitted on 22 Apr 2024
13 points (88.2% liked)

Selfhosted

40152 readers
573 users here now

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:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. 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.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

I think i have a stupid question but i couldn't find answer to it so far :( When i want to reach a service that i host on my own server at home from the local network at home, is using a public domain effective way to do it or should i always use server's IP when configuring something inside LAN? Is my traffic routed through the internet somehow when using domain even in LAN or does my router know to not do this?

top 8 comments
sorted by: hot top controversial new old
[–] TCB13@lemmy.world 6 points 6 months ago* (last edited 6 months ago) (2 children)

is using a public domain effective way to do it or should i always use server’s IP when configuring something inside LAN? Is my traffic routed through the internet somehow when using domain even in LAN or does my router know to not do this?

It depends.

If you control your router (not ISP provided) you can just go into the router settings and tell it to always resolve your public domain to the local machine IP. This will make it so any computer on the network running a DNS query will get a local IP for that domain instead of the public one. Quick and easy fix.

If you don't control it / don't apply the fix above, most likely your traffic is not routed through the internet because routers are usually configured for hairpinning / NAT loopback and they'll simply forward the traffic internally.

You can test what's going on by using the traceroute (or tracert on Windows) to find where the traffic is going. It will give you a line for each host your traffic has to go through in order to reach the destination. If you need help reading the output, just post it public IPs redacted.

[–] adidas423@lemmy.janiak.cc 2 points 6 months ago

Thanks for your reply, i'll try the traceroute thing when i'll be back home in a few days :)

[–] catloaf@lemm.ee 1 points 6 months ago (1 children)

If by "router" you mean the all-in-one box, yes. But even if you don't fully control the device, you can usually change DHCP DNS so that LAN clients will use your local DNS servers.

[–] TCB13@lemmy.world 2 points 6 months ago (1 children)

But even if you don’t fully control the device, you can usually change DHCP DNS so that LAN clients will use your local DNS servers.

Not all ISPs allow this. Mine for instance doesn't allow changing any LAN DHCP setting... fortunately they have an option to configure one of the ports as "bridge" and you'll get a public IP there so I can just plug my own equipment and do whatever I want.

[–] BearOfaTime@lemm.ee 0 points 6 months ago

Not all isps allow this.

Hence the "usually" in their statement.

[–] TheButtonJustSpins@infosec.pub 3 points 6 months ago

You want to split your domain so it resolves to a private IP internally and a public IP externally. So, your internal DNS server should return internal IPs.

[–] Decronym@lemmy.decronym.xyz 1 points 6 months ago* (last edited 6 months ago)

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer Letters More Letters
DHCP Dynamic Host Configuration Protocol, automates assignment of IPs when connecting to a network
DNS Domain Name Service/System
IP Internet Protocol
NAT Network Address Translation

4 acronyms in this thread; the most compressed thread commented on today has 9 acronyms.

[Thread #702 for this sub, first seen 22nd Apr 2024, 14:45] [FAQ] [Full list] [Contact] [Source code]

[–] atzanteol@sh.itjust.works 1 points 6 months ago* (last edited 6 months ago)

Some routers will allow you to reach the external IP from inside your network, some may not. Mine currently does which is great (I can access www.example.com which resolves to my external IP address and it is forwarded as though I were outside my network).

What I do is register public domains on "example.com" and I have a sub-domain for internal IPs (home.example.com). My local DNS server responds for home.example.com and forwards for the rest.

This makes it clear to me which address I will be getting. And since all my public web traffic goes through a reverse-proxy it lets me also have a name for the server itself. e.g. "music.example.com" may go through the reverse proxy for my music server, but "music.home.example.com" resolves to my music server directly. So I can use the latter for ssh and other things.